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.
请问是什么原因?

解决方案 »

  1.   

    写的这么清楚:java.io.FileNotFoundException: C:\in.txt (系统找不到指定的文件。)
    不存在这个文件C:\in.txt
      

  2.   

     File file  = new File("C:\\in.txt");
    改成
     File file  = new File("C://n.txt");
    然后再试试
      

  3.   

    顶楼上
    楼主仔细看看自己的路径吧。
    还有就是有可能文件扩展名被隐藏了,说不定是in.txt.txt呢
      

  4.   

    在java 中正斜杠“\”用来表示路径时,一个就可以了,而反斜杠“/”要两个是因为转义字符的存在,你的代码中两个正斜杠,这就有点无语了