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

java.io.ObjectOutputStream writeUTF() on solaris throws UTFDataFormatException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • core-libs
    • None

      java.io.ObjectOutputStream writeUTF() on solaris throws UTFDataFormatException

      On windows working
      jdk1.4 b46

      Test Program:
      --------------------------------------------------------
       
      import java.io.*;
       
        
      public class WriteReadUTF {
            
          public static void main(String[] args) throws Exception {
         StringBuffer stringBuffer = new StringBuffer("a");
      //generate a stringbuffer with 65535 length by appending to stringBuffer
      for( int i = 0; i < 65534; i++) {
      stringBuffer.append("a");
      }

      String string65535 = stringBuffer.toString();
      //delete if file exists
             File f = new File("utfTestFile");
              if (f.exists()) {
                 f.delete();
             }
             try {

      FileOutputStream wstream = new FileOutputStream("utfTestFile");
      FileInputStream rstream = new FileInputStream("utfTestFile");
      ObjectOutputStream wfile = new ObjectOutputStream(wstream);
                 wfile.writeUTF(string65535);////writing string of length 65535
                 wfile.close();

      ObjectInputStream rfile = new ObjectInputStream(rstream);

      String rString65535 = rfile.readUTF();

      if ( !(rString65535.equals(string65535))) {
      throw new Exception("data1 not correctly read in WriteReadUTF()");
      }

      rfile.close();
      System.out.println ("WriteReadUTF pass");

      } catch (Exception e) {
         System.out.println ("Exception thrown in WriteReadUTF Failed " + e);
             e.printStackTrace();
             }
       
         }
      }
         
       ---------------------------------result------------------------
      javapro:/home/pande/merlin/bugs/io/WriteReadUTF 23 % java WriteReadUTF
      Exception thrown in WriteReadUTF Failed java.io.UTFDataFormatException
      java.io.UTFDataFormatException
              at java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:1827)
              at java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:1658)
              at java.io.ObjectOutputStream.writeUTF(ObjectOutputStream.java:787)
              at WriteReadUTF.main(WriteReadUTF.java:25)

            mwarressunw Michael Warres (Inactive)
            spandeorcl Shantaram Pande (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: