import java.io.*;
class Test{
public static void main(String args[]){
File file = new File(args[0]);
String str;
try{
// FileReaderを作り、それを入力としてBufferedReaderにつなげる
BufferedReader br = new BufferedReader(new FileReader(file));
// 1行読み込み
str = br.readLine();
// ファイルの終了まで続ける
while(str != null){
System.out.println(str);
// 1行読み込み
str = br.readLine();
}
// クローズ
br.close();
// ファイルの終了まで続ける
}catch(FileNotFoundException e){
System.err.println("ファイルが見つかりません:" + args[0]);
}catch(Exception e){
System.err.println(e);
}
}
}
|