import java.io.*;
public class Jpro10_4
{
public static void main(String[] args)
{
File file = new File("C:\\in.txt");
try
{
FileInputStream fis = new FileInputStream(file);
int len;
byte by[] = new byte[1024];
while((len = fis.read(by))!=-1)
{
String str = new String(by,0,len);
System.out.println("从文件in.txt中读取出的内容是:"+str);
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}
结果却是--------------------Configuration: <Default>--------------------
java.io.FileNotFoundException: C:\in.txt (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at Jpro10_4.main(Jpro10_4.java:9)Process completed.
请问是什么原因?
public class Jpro10_4
{
public static void main(String[] args)
{
File file = new File("C:\\in.txt");
try
{
FileInputStream fis = new FileInputStream(file);
int len;
byte by[] = new byte[1024];
while((len = fis.read(by))!=-1)
{
String str = new String(by,0,len);
System.out.println("从文件in.txt中读取出的内容是:"+str);
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}
结果却是--------------------Configuration: <Default>--------------------
java.io.FileNotFoundException: C:\in.txt (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at Jpro10_4.main(Jpro10_4.java:9)Process completed.
请问是什么原因?
解决方案 »
- 一个关于file.exists方法的问题
- 惊天错误:第一次知道JAVA编译器居然出错,大家看看错误详细提示信息:
- 在类中创建本来对象的问题,求解释!!!
- 别笑我.请问写JAVA程序是用记事本吗?
- 帮忙解释一下下面的this关键字
- 如何把sql server 数据库中字段类型为tinyint 的字段写出来 在线等待
- statment.excutequery(sqlString)执行出错?
- JBuilder怎样和数据库控件建立联系?解决了,就给分!
- 请问哪儿有jbuilder的中文版教程下载?100分相送
- 如何配置,从sun网站下载的东东(我不知道该怎么称乎她,是不是脚虚拟机)
- 新手求指点!
- 很老的一道题了,大家帮忙看看
不存在这个文件C:\in.txt
改成
File file = new File("C://n.txt");
然后再试试
楼主仔细看看自己的路径吧。
还有就是有可能文件扩展名被隐藏了,说不定是in.txt.txt呢