這是我在互聯網上找到的用於讀取文件行並且使用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());
}
}
}
請幫助我,爲什麼它打印此錯誤。 謝謝
我有這樣一個文本文件! ! – user472221 2010-11-29 10:00:43
這也是我的項目的位置:C:\ Documents and Settings \ icc \ workspace \ Hoffman Project – user472221 2010-11-29 10:02:18