Jump to content

  • Log In with Google      Sign In   
  • Create Account

Bench3

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

#4969935 File IO

Posted by Bench3 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 :)

Eg:

[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 :)

~Ben


PARTNERS