Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4025564

ObjectInputStream.readObject() failures when size of Object

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • 1.1, 1.1.2
    • core-libs
    • generic, x86, sparc
    • generic, solaris_2.5.1, windows_95, windows_nt



      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!###@###.###

      ======================================================================

            rriggs Roger Riggs
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: