Newer
Older
package org.josast.SIDS.app;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.josast.SIDS.SIDSData;
import org.josast.SIDS.Station;
public class SendFile {
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
private SIDSData sids = new SIDSData();
private BufferedReader lecteurAvecBuffer = null;
private String ligne;
public void initSIDS() {
sids.setStation(new Station());
sids.setNoradID(99990);
}
public void openFile(final String file) {
try {
lecteurAvecBuffer = new BufferedReader(new FileReader(file));
} catch (FileNotFoundException exc) {
System.out.println("Erreur d'ouverture");
}
}
public void readFile() {
boolean first = false;
Date dateref = null;
try {
while ((ligne = lecteurAvecBuffer.readLine()) != null) {
String[] result1 = ligne.split("=");
String[] date = result1[1].split("]");
String[] trame = result1[2].split("]");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
"E MMM dd hh:mm:ss z yyyy", Locale.ENGLISH);
System.out
.println("date : " + date[0] + " - Trame " + trame[0]);
Date date2 = simpleDateFormat.parse(date[0]);
if (first == false) {
dateref = date2;
first = true;
} else {
System.out.println(
(date2.getTime() - dateref.getTime()) / 1000);
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void closeFile() {
try {
lecteurAvecBuffer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] argv) throws IOException {
SendFile sf = new SendFile();
sf.openFile(argv[0]);
sf.initSIDS();
sf.readFile();
sf.closeFile();
}