First page Back Continue Last page Overview Graphics
Reading a text file line by line (The good way)
//read the file line by line – and remove empty lines
String line;
- while( (line = bufIn.readLine()) != null )
- if(!line.equals(“”))
- bufOut.write(line,0,line.length());
- bufOut.newLine();
- }
- //don't forget to flush and close streams!
- bufOut.flush();
- bufOut.close();
- fileIn.close();
- }