I am trying to copy contents of pqr.txt to xyz.txt. I have manually created a file pqr.txt in the same folder of class demo. I am getting the Error --- > File does not exist. java.io.FileNotFoundException: pqr.txt (The system cannot find the file specified)
With the code that you're using to read a file, the txt file that you are reading must be placed in the root directory of your project (if you're using an IDE). If you are compiling and running it from command line, you just need to put the txt file in the same folder where your .class file is.
Also, couple of things as a side note: you should follow convention for naming classes (first letter always capital) and you should close streams (or free any resources whatsoever in other applications) in finally block or use try-with-resources statement introduced in latest JDK.
The quieter you are, the more you are able to hear.
Tony Docherty wrote:If you ever need to find out which directory your system is using as root just add the following line to your code and see what prints to the console:
Joined: Sep 20, 2012
well thanks to Mr. Biswas, Mr. Docherty & Mr. Sokolovic
Mr. Sokolovic i followed your instruction , got success ( thumbs up). I placed the pqr.txt in root directory. After running the program it created the file xyz.txt with all contents copied.
Henceforth i will use code tags.
To find out which directory your system is using as root. Mr. Docherty & Mr. Sokolovic thumbs up for both