我正在尝试使用FileInputStream和FileOutputStream.But读取文件中的数据,我收到一个Exception,说File.io.FileNotFoundException。
我已将文件abc.txt保存在我的类IoConcepts所在的同一个文件夹中
任何人都可以指导我做错了吗?
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 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)