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

jdk1.1.7 FileReader/FileWriter behaves different than jre1.1.6

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P2 P2
    • None
    • 1.1.7
    • core-libs
    • x86
    • windows_95



      Name: diC59631 Date: 10/08/98


      /*
      The following code is intended to copy a file.

      I compile on Solaris 2.5.1 jdk1.1.6 and move the
      cf.jar file to a windows95 machine.

      When run with jre116 (rt.jar) , it works fine.

      When run with jdk1.1.7\bin\jre (classes.zip) , it
      appears to work, but the files are not identical.
      (They are the same size, but a 'fc' command
      shows differences. The file I try to copy is a
      compiled executable (.exe file)
      */

      import java.io.File;
      import java.io.FileReader;
      import java.io.FileWriter;
      /**
      Test to 'copy' a file
      */
      public class cf {
      public String msg;
      //
      public cf(String inFileName) {
      System.out.println("inputFile ->" + inFileName + "<");
      File from = new File(inFileName);
      FileReader fr;
      try {
      fr = new FileReader(from);
      } catch(Exception e) {
      msg = "<copyFile> file not found->" + from.getPath();
      return;
      }
      int size = (int) from.length();
      char cbuf[] = new char[size];
      File to = new File(inFileName + ".copy");
      try {
      FileWriter tow = new FileWriter(to);
      int bytes_read = fr.read(cbuf,0,size);
      if(bytes_read != size)
      {
      String s = "<copyFile> internal problem";
      s=s+ size + " expected from " + from.getPath();
      s=s + "(" + bytes_read + ")";
      msg = s;
      return;
      }
      fr.close();
      tow.write(cbuf,0,size);
      tow.close();
      } catch(Exception e) {
      msg = e.toString();
      return; }
      }

      public static void main(String arg[]) {
      if(arg.length < 1)
      {
      System.out.println("reqd 1st argument missing - should be inputfilename");
      System.exit(1);
      }
      cf x = new cf(arg[0]);
      if(x.msg != null)
      System.out.println(x.msg);
      }
      }
      (Review ID: 40161)
      ======================================================================

            mr Mark Reinhold
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: