I want to save a captured packet in TCPDump format. I'm using Java with JPCap library. However, I'm not able to use JpcapWriter.writePacket() function, it gives me a JVM error. This is the code that is causing the JVM error: captor=JpcapCaptor.openDevice(interfaceList[interfaceNumber], 65535, true, 20); captor.setFilter("ip and tcp",true);
JpcapWriter writer=JpcapWriter.openDumpFile(captor,"pass.txt");
for(int i=0;i<10;i++){
//capture a single packet
Packet packet=captor.getPacket();
//save it into the opened file
writer.writePacket(packet);
}
writer.close();
Any other way to save it into a file in TCPformat?