Thread: list
View Single Post
  #2 (permalink)  
Old 11-19-2007, 10:36 PM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Code:
import java.io.*; public class ReadingAFile { public static void main(String[] args) { String[] strs = new String[20]; int count = 0; BufferedReader br = null; try { File file = new File("readingAFile.txt"); br = new BufferedReader( new InputStreamReader( new FileInputStream(file))); String line; while((line = br.readLine()) != null) { strs[count++] = line; } br.close(); } catch(IOException e) { System.out.println("read error: " + e.getMessage()); } for(int j = 0; j < count; j++) { System.out.println(strs[j]); } } }
readingAFile.txt
Code:
Waking Ned Devine No Country for Old Men The Postman Clearcut The Princess Bride
Reply With Quote