本帖最后由 霍明波 于 2012-8-26 12:10 编辑
在MyEclipse中
package com.inheima;
import java.io.*;
public class InputStreamDemo {
public static void main(String[] args)throws Exception{
FileInputStream is = null;
is = new FileInputStream("abc.txt");
byte[] by = new byte[5];
int num;
while((num=is.read(by))!=-1){
System.out.println(new String(by,0,by.length));
}
}
}
出现如下异常
Exception in thread "main" java.io.FileNotFoundException: abc.txt (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at com.inheima.ImportStreamDemo.main(ImportStreamDemo.java:6)
问一下,这个怎么路径怎么处理 ,要把exicise.txt文件放在哪,路径怎么看,第一次用Eclipse不知道怎么处理 ,望给解决。
|
|