I am trying to read the data in the file using FileInputStream and FileOutputStream.But,I am getting an Exception saying File.io.FileNotFoundException.
I have saved the file abc.txt in the same Folder where my class IoConcepts is
Can Anyone guide me what I am doing wrong?
package io;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class IoConcepts
{
public static void main(String[] args) throws FileNotFoundException,IOException
{
FileInputStream fis=new FileInputStream("abc.txt");
FileOutputStream fos=new FileOutputStream("abcd.txt");
int c;
while((c=fis.read())!=-1)
{System.out.println(c);
fos.write(c);
}
}
}
Exception:
Exception in thread "main" java.io.FileNotFoundException: abc.txt (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at io.IoConcepts.main(IoConcepts.java:13)