Skip to content

Instantly share code, notes, and snippets.

@pope
Created January 2, 2009 20:00
Show Gist options
  • Save pope/42650 to your computer and use it in GitHub Desktop.
Save pope/42650 to your computer and use it in GitHub Desktop.
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class FileReadTest {
public static void main(String[] args) {
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("mytext.txt"));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (IOException ex) {
Logger.getLogger(FileReadTest.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
br.close();
} catch (IOException ex) {
Logger.getLogger(FileReadTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment