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

FileNotFoundException thrown when actually file isn't writeable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • None
    • sparc
    • solaris_2.5.1

      This is a very minor bug. If a file isn't writeable and a program
      attempts to write to it, the exception thrown is java.io.FileNotFoundException.
      This is a bit confusing, since the file does exist. Suppose the file
      /home/mrm/notwriteable exists but has write permissions turned off.
      The following program demonstrates the bug. Thanks to Charlie Lai for
      figuring this out.

      import java.io.*;
       
      public class WriteFile {
          public static void main(String args[]) {
              try {
                  PrintWriter out = new PrintWriter
                              (new BufferedWriter
                              (new FileWriter("/home/mrm/notwriteable")));
                  out.println("hi there");
                  out.flush();
              } catch (Exception e) {
                  System.out.println(e.toString());
              }
          }
      }

            Unassigned Unassigned
            mmuellersunw Marianne Mueller (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: