File outFile = new File(folder, infile.getName().replaceAll("\\.gz$", ""));
if (outFile.isFile())//already exists
return outFile;
fos = new FileOutputStream(outFile);
byte[] buf = new byte[100000];
int len;
while ((len = gin.read(buf)) > 0) {
fos.write(buf, 0, len);
}
fos.close();
if (deleteGzipfileOnSuccess) {
infile.delete();
}
return outFile;
} finally {
if (gin != null) {
gin.close();
}
if (fos != null) {
fos.close();
}
}
}
private void readDEEPsample() throws PcapNativeException, InterruptedException, NotOpenException, IOException {
String filename = "data%2Ffeeds%2F20180628%2F20180628_IEXTP1_DEEP1.0.pcap.gz";
PcapHandle handle = Pcaps.openOffline(unGzip(new File(filename), false).getPath(),
PcapHandle.TimestampPrecision.NANO);
handle.loop(-1, new PacketListener() {
@Override
public void gotPacket(Packet packet) {
byte[] data = packet.getPayload().getPayload().getPayload().getRawData();
IEXSegment block = IEXDEEPMessageBlock.createIEXSegment(data);
System.out.println(block);
}
});
handle.close();
}
public static void main(String[] args) {
IexDeepReader reader = new IexDeepReader();
try {
reader.readDEEPsample();
} catch (PcapNativeException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (NotOpenException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}