savestringbuffer.java

来自「Developing Games in Java 源代码」· Java 代码 · 共 29 行

JAVA
29
字号
import java.io.*;
import java.util.*;

class SaveStringBuffer {

public static void main (String[] args) {

    StringBuffer sb = new StringBuffer("Beam me up!");

    try {
        FileOutputStream fos = new FileOutputStream("sb.ser");
        ObjectOutputStream oos = new ObjectOutputStream(fos);

        oos.writeObject(sb);

        //Set bag = new HashSet();
        //bag.add(new Object());

        //oos.writeObject(bag);

        oos.close();

    } catch (IOException ioException) {
        System.out.println(ioException);
    }
}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?