这是我在互联网上找到的用于读取文件行的代码,我也使用
eclipse,并在其参数字段中将文件名称作为SanShin.txt传递.但它会打印:
Error: textfile.txt (The system cannot find the file specified)
码:
public class Zip {
public static void main(String[] args){
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("textfile.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}
请帮我解释为什么会出现这个错误.
谢谢