Reads in simple addresses from a user specified file.
@author
@version
import java.util.Scanner;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.util.InputMismatchException;
public class AddressParserSimple{
public static void main( String[] args ){
Scanner stdinScanner = new Scanner( System.in );
String filename;
BufferedReader reader = null;
String line1;
String line2;
String line3;
try{
System.out.print("Please enter the output filename: ");
filename = stdinScanner.next();
reader = new BufferedReader( new FileReader( filename ) );
line1 = reader.readLine();
while( line1 != null ){
line2 = reader.readLine();
line3 = reader.readLine();
reader.readLine();
System.out.println("Found address: \"" + line1 + ", " + line2 + ", " + line3 + "\"" );
line1 = reader.readLine();
}
}catch( FileNotFoundException e ){
System.err.println("Sorry, that was not a valid filename: " + e.getMessage() );
return;
}catch( InputMismatchException e){
System.err.println("Error, unable to parse input!" );
return;
}catch( Exception e){
System.err.println("ERROR: " + e.getMessage() );
return;
}finally{
if(reader != null ){
try{
reader.close();
}catch( Exception e ){
System.err.println("Error closing reader: " + e.getMessage());
}
}
}
}
}