import java.io.*;
public class demo
{
public static void main(
String args[])
{
try
{
FileReader fr = new FileReader("pqr.txt");
FileWriter fw = new FileWriter("xyz.txt");
int k;
while( ( k = fr.read() ) != -1 )
{
fw.write(k);
System.out.print((char) k);
}
fw.close();
fr.close();
}
catch(FileNotFoundException e)
{
System.out.println("File does not exist. " + e);
}
catch(IOException e)
{
System.out.println("Some I/O problem. " + e);
}
}
}
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)