Hi, im having trouble reading a hex file in java. I want my program to search through the file and look for IP and ARP packets and then print out there values and their correpsonding bytes (ip, headerlen, id, checksum, etc) I have some code for it but its not quite working. Could some one please give me some tips on how to improve my code. Cheers:
private void getPacketData() throws IOException
{
System.out.println("Packet Data information: ");
String line = "";
String[] values = null;
InputStream src = new FileInputStream("C:/Users/Andrew/workspace/tcpdump_text_file");
BufferedReader reader = new BufferedReader(new InputStreamReader(src));
while(src.read() != -1)
{
for(int i = 0; i < 20; i++) {
line = reader.readLine();
values = line.split("");
if(values.length > 5 && values[4].matches("0800"))
{
System.out.println("IP packet"); showbytes(2, src);
}
else if(values.length > 5 && values[4].matches("0806"))
{
System.out.println("ARP packet"); showbytes(2, src);
}
else {
showbytes(2, src);
}
}
}