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