List of usage examples for java.io ObjectOutputStream flush
public void flush() throws IOException
From source file:shutdown.java
License:asdf
public static void main(String[] args) throws ClassNotFoundException, IOException { FileOutputStream fos = new FileOutputStream("objects.tmp"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject("asdf"); oos.flush(); fos.close();//from w w w . java 2 s . c o m FileInputStream fis = new FileInputStream("objects.tmp"); ObjectInputStream ois = new ObjectInputStream(fis); String t = (String) ois.readObject(); fis.close(); }
From source file:Main.java
public static void main(String[] args) { Card card = new Card(); try {/* w w w .j a v a2 s.c om*/ FileOutputStream out = new FileOutputStream("card.out"); ObjectOutputStream oos = new ObjectOutputStream(out); oos.writeObject(card); oos.flush(); oos.close(); } catch (Exception e) { System.out.println("Problem serializing: " + e); } }
From source file:Main.java
public static void main(String[] args) throws Exception { String s = "Hello World from java2s.com"; FileOutputStream out = new FileOutputStream("test.txt"); ObjectOutputStream oout = new ObjectOutputStream(out); oout.writeObject(s);//from w w w . j a v a 2s . c om oout.flush(); oout.close(); Main ois = new Main(new FileInputStream("test.txt")); System.out.println((String) ois.readObjectOverride()); ois.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { String s = "Hello World from java2s.com"; FileOutputStream out = new FileOutputStream("test.txt"); ObjectOutputStream oout = new ObjectOutputStream(out); oout.writeUTF(s);//from ww w .j a va 2s. c o m oout.flush(); oout.close(); Main ois = new Main(new FileInputStream("test.txt")); String[] list = { Serializable.class.getName() }; System.out.println(ois.resolveProxyClass(list)); ois.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileOutputStream out = new FileOutputStream("test.txt"); ObjectOutputStream oout = new ObjectOutputStream(out); oout.writeObject(new Example()); oout.flush(); oout.close();/*from w w w . ja v a2 s. c o m*/ ObjectInputStream ois = new ObjectInputStream(new FileInputStream("test.txt")); Example a = (Example) ois.readObject(); System.out.println(a.s); ois.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileOutputStream out = new FileOutputStream("test.txt"); ObjectOutputStream oout = new ObjectOutputStream(out); oout.writeUTF("Hello World from java2s.com"); oout.flush(); oout.close();/*from w ww .j av a 2 s . co m*/ ObjectInputStream ois = new ObjectInputStream(new FileInputStream("test.txt")); for (int i = 0; i < ois.available();) { System.out.print((char) ois.read()); } ois.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { byte[] cbuf = new byte[10]; FileOutputStream out = new FileOutputStream("test.txt"); ObjectOutputStream oout = new ObjectOutputStream(out); oout.writeUTF("Hello World from java2s.com"); oout.flush(); oout.close();// w w w . j ava2 s . c o m ObjectInputStream ois = new ObjectInputStream(new FileInputStream("test.txt")); ois.read(cbuf, 0, 7); for (int i = 0; i < 7; i++) { System.out.print((char) cbuf[i]); } ois.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { short b = 32767; FileOutputStream out = new FileOutputStream("test.txt"); ObjectOutputStream oout = new ObjectOutputStream(out); // write something in the file oout.writeShort(b);/* ww w .j a va 2 s . c o m*/ oout.flush(); oout.close(); // create an ObjectInputStream for the file we created before ObjectInputStream ois = new ObjectInputStream(new FileInputStream("test.txt")); // read and print the short System.out.println(ois.readUnsignedShort()); ois.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { byte b = 127; FileOutputStream out = new FileOutputStream("test.txt"); ObjectOutputStream oout = new ObjectOutputStream(out); // write something in the file oout.writeByte(b);//from ww w . ja v a 2 s .c om oout.flush(); oout.close(); // create an ObjectInputStream for the file we created before ObjectInputStream ois = new ObjectInputStream(new FileInputStream("test.txt")); // read and print the unshared object System.out.println(ois.readUnsignedByte()); ois.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileOutputStream out = new FileOutputStream("test.txt"); ObjectOutputStream oout = new ObjectOutputStream(out); oout.writeObject(new Example()); oout.flush(); oout.close();/*w w w. j av a2s.c o m*/ ObjectInputStream ois = new ObjectInputStream(new FileInputStream("test.txt")); Example a = (Example) ois.readObject(); System.out.println(a.s); a.validateObject(); ois.close(); }