import java.io.*; import java.util.*; import java.text.*; public class StockData { public static void main(String args[]) { String stock_name; Date quote_date = null; float high_p, low_p, closing_p; try { String line_str; int line_number; BufferedReader ds = new BufferedReader (new FileReader("quote.dat")); DateFormat df = DateFormat.getDateInstance(); while( (line_str = ds.readLine()) != null ) { StringTokenizer st = new StringTokenizer(line_str); // extract tokens and convert to appropiate types stock_name = st.nextToken(); try { quote_date = df.parse(st.nextToken()); } catch ( ParseException e ) { System.out.println("Parse error: " + e); } high_p = Float.valueOf(st.nextToken()).floatValue(); low_p = Float.valueOf(st.nextToken()).floatValue(); closing_p = Float.valueOf(st.nextToken()).floatValue(); // display extract values System.out.println("Stock Symbol :" + stock_name); System.out.println("Quote Date :" + quote_date); System.out.println("Price: high:" + high_p + " low:" + low_p + " close:" + closing_p); System.out.println(); } ds.close(); } catch (IOException e) { System.out.println("File error: " + e); } } }