hi
Im reading data from a file and putting into an array ,I know this works fine because I can loop thru the array and print the contents to the console.However because Im adding the file contents within a while loop ,I dont seem to be able to use the array outside of the loop.So when I actually try to use it ,there is only one item in it instead of 307.
Im obviously doing something fundamentally wrong..any ideas?Code:File file = new File("c:\\test_list.txt"); try { // read in the raw file BufferedReader reader = new BufferedReader(new FileReader(file)); String s; StringTokenizer t; while((s=reader.readLine())!=null) { items = s.split(" "); for (int j = 0; j < items.length; j++) { if(items[j]==null){ items[j]="\n";} System.out.print(items[j]+"\n"); //prints all values } reader.close(); } catch (Exception e){ }
Thanks


Reply With Quote


Bookmarks