import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class FileReadSkelton {
public void read(File file) throws Exception {
BufferedReader in = null;
try{
in = new BufferedReader(new FileReader(file));
String line;
while( (line=in.readLine() ) !=null ) {
System.out.println("行データ:" + line);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
throw new Exception("ファイルがありません" + file.getPath() );
} catch(Exception e){
e.printStackTrace();
throw e;
}finally{
try {
if( in != null ) {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
良かったらクリックお願いします→
