Advertisement
oona

Read To File

Sep 16th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileReader;
  3. import java.io.IOException;
  4.  
  5. public class fileReaderExample {
  6.  
  7.     public static void main(String[] args) {
  8.         // TODO Auto-generated method stub
  9.  
  10.         BufferedReader br = null;
  11.        
  12.         try
  13.         { //beginning of try
  14.             String sCurrentLine = "";
  15.             br = new BufferedReader (new FileReader("C:\\Users\\Oona\\My Documents\\dataFileExample.txt"));
  16.            
  17.             while((sCurrentLine = br.readLine()) != null)
  18.             {
  19.                 System.out.println(sCurrentLine);
  20.             }
  21.         }// end of try
  22.         catch (IOException e){}
  23.         finally
  24.         {
  25.             try
  26.             { //beginning of try
  27.                 if(br != null) br.close();
  28.             } //end of try
  29.             catch(IOException ex){}
  30.         }
  31.        
  32.     } //class ends
  33.  
  34. } //program ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement