Created
January 2, 2009 20:00
-
-
Save pope/42650 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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