Skip to content

Instantly share code, notes, and snippets.

@ksakae1216 ksakae1216/new
Created Jun 11, 2017

Embed
What would you like to do?
// try-with-resourcesでファイル読み込み
private void newFileRead(String file) {
try(FileInputStream fi = new FileInputStream(file);
InputStreamReader in = new InputStreamReader(fi);
BufferedReader br = new BufferedReader(in)) {
// ファイル読み込み
String line;
while( (line = br.readLine()) != null) {
System.out.println(line);
}
} catch(Exception e) {
} finally {
// クローズ処理不要
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.