source: liacs/se/RouteGUI/src/routegui/GPS.java@ 378

Last change on this file since 378 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 1.5 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package routegui;
6
7import java.io.*;
8import java.util.logging.Level;
9import java.util.logging.Logger;
10
11
12/**
13 *
14 * @author rick
15 */
16public class GPS {
17 /* http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml */
18
19 private DataInputStream in;
20 private BufferedReader br;
21 public GPRMC data = new GPRMC();
22
23 /* http://www.codepedia.com/1/The+GPRMC+Sentence */
24
25 public void GPS() {
26 }
27
28 public void init(String inputFile) {
29 try {
30 FileInputStream fstream = new FileInputStream(inputFile);
31 in = new DataInputStream(fstream);
32 br = new BufferedReader(new InputStreamReader(in));
33
34 } catch (FileNotFoundException ex) {
35 Logger.getLogger(GPS.class.getName()).log(Level.SEVERE, null, ex);
36 }
37 }
38
39 public boolean next() {
40 String strLine;
41 Boolean result;
42 /* Try fething new line, bail out if fails */
43 while (true) {
44 try {
45 strLine = br.readLine();
46 if (strLine == null) {
47 return false;
48 }
49 } catch (IOException ex) {
50 return false;
51 }
52 result = data.process(strLine);
53 if (result) {
54 return true;
55 }
56 }
57 }
58
59 @Override
60 protected void finalize() throws Throwable
61 {
62 in.close();
63 super.finalize();
64 }
65}
Note: See TracBrowser for help on using the repository browser.