/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package routegui; import java.io.*; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author rick */ public class GPS { /* http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml */ private DataInputStream in; private BufferedReader br; public GPRMC data = new GPRMC(); /* http://www.codepedia.com/1/The+GPRMC+Sentence */ public void GPS() { } public void init(String inputFile) { try { FileInputStream fstream = new FileInputStream(inputFile); in = new DataInputStream(fstream); br = new BufferedReader(new InputStreamReader(in)); } catch (FileNotFoundException ex) { Logger.getLogger(GPS.class.getName()).log(Level.SEVERE, null, ex); } } public boolean next() { String strLine; Boolean result; /* Try fething new line, bail out if fails */ while (true) { try { strLine = br.readLine(); if (strLine == null) { return false; } } catch (IOException ex) { return false; } result = data.process(strLine); if (result) { return true; } } } @Override protected void finalize() throws Throwable { in.close(); super.finalize(); } }