Duplicate :
|
|
Relates :
|
|
Relates :
|
Name: el35337 Date: 01/13/97 Please compile this source and run. ---- source -------------------------------------------------------- import java.io.*; Please compile this source and run. ---- source -------------------------------------------------------- import java.io.*; public class SerializeTest { // static int size = 65535; // <-- OK static int size = 65536; // <-- NG public static void main(String[] args) { try { StringBuffer sb = new StringBuffer(); String in; String out; File objfile = new File("test.obj"); File txtfile = new File("test.txt"); for(int i=0;i<size;i++) sb.append('a'); out = sb.toString(); ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(objfile)); os.writeObject(out); os.flush(); os.close(); System.err.println("write: " + out.length() + " chars."); ObjectInputStream is = new ObjectInputStream(new FileInputStream(objfile)); in = (String)is.readObject(); is.close(); System.err.println("read: " + in.length() + " chars."); FileOutputStream f = new FileOutputStream(txtfile); f.write(in.getBytes()); f.flush(); f.close(); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(System.err); } } } ---- end of source -------------------------------------------------- Fujitsu fujitsu!fb.se.fujitsu.co.jp!###@###.### ======================================================================
|