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

java.io.FileWriter constructor throws incorrect exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1
    • core-libs
    • None
    • x86
    • windows_nt



      Name: mc57594 Date: 02/12/97


      If I construct a java.io.FileWriter for a file which is being
      held open by the "more" program (Windows NT), it throws
      java.io.FileNotFoundException. In fact, the file is present.

      The following program demonstrates this if it's run while the
      argument file is held open in a "-- More --" prompt.

      import java.io.BufferedReader;
      import java.io.BufferedWriter;
      import java.io.File;
      import java.io.FileReader;
      import java.io.FileWriter;
      import java.io.PrintWriter;
      import java.io.IOException;

      public
      class tt2 {
        static public void main(String argv[]) throws IOException {
          if (argv[1].equals("R")) {
            new BufferedReader(new FileReader(new File(argv[0])));
            System.out.println("opened db R");
          }
          else {
            new FileWriter(new File(argv[0]));
            System.out.println("opened db W");
          }
          System.in.read();
        }
      }

      D:\temp>java tt2 foo.bar W
      java.io.FileNotFoundException: foo.bar
              at java.io.FileOutputStream.<init>(FileOutputStream.java:59)
              at java.io.FileOutputStream.<init>(FileOutputStream.java:93)
              at java.io.FileWriter.<init>(FileWriter.java:50)
              at tt2.main(tt2.java:17)


      company - Object Design, Inc. , email - ###@###.###
      ======================================================================

            mr Mark Reinhold
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: