View Single Post
Join Date: Dec 2007
Posts: 1,718
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 230
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: How to make an array in text file (help..)

 
0
  #9
Nov 18th, 2008
I have tried this:
  1. public static void main(String[] args) {
  2. BufferedReader lnr = null;
  3. String line = null;
  4. try {
  5. lnr = new BufferedReader (new FileReader("accountList.txt"));
  6. for (line = lnr.readLine(); line!=null; line = lnr.readLine()) {
  7.  
  8. String account[] = line.split(" ");
  9.  
  10. System.out.println(account[0]);
  11. }
  12.  
  13. lnr.close();
  14. } catch (Exception e) {
  15. System.out.println("An error has occured: "+e.getMessage());
  16. //e.printStackTrace();
  17. }
  18. }

The file has these:
12345 1234 200000 Jerry Lopez
55555 1234 200000 Jerry Lopez
And it printed:

12345
55555
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote