Added utility to analyze telegrams.

pull/22/head
weetmuts 2019-04-15 22:04:23 +02:00
rodzic 966d3dbf2a
commit 957c47cf6a
1 zmienionych plików z 47 dodań i 0 usunięć

47
utils/Analyze.java 100644
Wyświetl plik

@ -0,0 +1,47 @@
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Analyze {
public static void main(String[] args)
{
String match = args.length > 1 ? args[1] : "";
BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(
args[0]));
String prevline = reader.readLine();
String line = reader.readLine();
while (line != null) {
if (line.indexOf(match) >= 0) {
boolean space = false;
for (int i=0; i<line.length()-4; i+=2) {
if (i < prevline.length()-1 && i < line.length()-1 &&
line.charAt(i) == prevline.charAt(i) &&
line.charAt(i+1) == prevline.charAt(i+1))
{
space = true;
}
else
{
if (space) {
System.out.print(" ("+i/2+")");
space = false;
}
System.out.print(line.charAt(i));
System.out.print(line.charAt(i+1));
}
}
System.out.println();
prevline = line;
}
line = reader.readLine();
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}