Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 08 Aug 2012
Offline Last Active Sep 14 2012 03:51 PM

#4969935 File IO

Posted by on 15 August 2012 - 02:31 PM

I would suggest not using a do while loop and doing the following:

Instead of a do while loop, just make it a while loop :)


[source lang="java"] public void readFile() throws IOException{ InputStream stream = this.getClass().getResourceAsStream(filePath+fileName); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String line; while(!line.equals("-END_OF_STREAM-")){ //Read each line of the file //Each line will correspond to separate entities. End characters will denote the end of an entity's data //Each line will be read, 'decrypted' and then set into the elements ArrayList line = reader.readLine(); lines.add(line); System.out.println(line); } //<<<<<<<<<< reader.close(); stream.close(); }[/source]

Hope this works :)