it mentions that there are 2 ways to create a file 1. Invoke the createNewFile() method on a File ojbect.
2. Create a Reader or a Writer or a Stream. Specifically, create a FileReader, a FileWriter, a PritWriter, a FileInputStream, or a FileOutputStream. Whenever you create an instance of one of those classes, you automatically create a file, unless one already exists.
I tried the following set of codes one by one
the first 3 created a new file as described in the book. but for the last 2(FileReader and FileInputStream), FileNotFoundException.
can someone explain me what's wrong with my code???
Terence, No Reader or InputStream will create a file ,if the file not exists.It will throw an FileNotFoundException if there is a directory exits name being the same as the file or does not finds the file specified. I think this is a errata in K&B book.