Error
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.

strline

Read Text File
Monday, 25 April 2011 15:48
// Read input from a text file. Paste input handling code in the while loop


public void readFile(String filename){
try{
FileInputStream fstream = new FileInputStream(filename);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;

//read line per line
while ((strLine = br.readLine()) != null) {

// input
// handling
// code

}

//Close stream
in.close();
}catch (Exception e){
e.printStackTrace();
}



}

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/pQqLxRTGx-k/13155

 


Taxonomy by Zaragoza Online