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

(spec) FileWriter constructors should document FileNotFoundException

XMLWordPrintable

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

      To: ###@###.###
      Subject: FileWriter throws wrong exception
      Comments: Hyperbole mail buttons accepted, v3.16.
      From: Steve Kelem <###@###.###>


      java.io.FileWriter throws the FileNotFoundException when trying to write to
      a read-only file.

      Here's some sample code that exercises the bug. You will need to create a
      read-only file called "a" to exercise the bug.

      import java.io.*;
      import java.util.*;

      public class iotest {
        static FileWriter ftarget = null;
        static PrintWriter target = null;
          /**
           * Constructor.
           */
        public iotest() {
        }

        static void write_files(String File_A)
             throws IOException
        {
          ftarget = new FileWriter(File_A);
          target = new PrintWriter(ftarget);
          target.println("This is line 1 of file A.");
          ftarget.flush();
          ftarget.close();
        }

        public static void main(String args[])
             throws IOException
        {
          write_files("a");
        }
      }

      I hope this helps,
      /7\'7 Steve Kelem (408)879-5347 ###@###.###
      \\ ` Xilinx FAX: (408)377-3259
      // 2100 Logic Drive
      \\/.\ San Jose, California 95124

      ****

      This is reproducable on build 122.

      sfoster@eng 1997-06-10

            iris Iris Clark
            sgfoster Stephen Foster (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: