package org.contikios.cooja.plugins.analyzers;

import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.File;

public class PcapExporter {

  DataOutputStream out;

  public PcapExporter() throws IOException {
  }

  public void openPcap(File pcapFile) throws IOException {
    if (out != null) {
      closePcap();
    }
    if (pcapFile == null) {
      /* pcap file not specified, use default file name */
      pcapFile = new File("radiolog-" + System.currentTimeMillis() + ".pcap");
    }
    out = new DataOutputStream(new FileOutputStream(pcapFile));
    /* pcap header */
    out.writeInt(0xa1b2c3d4);
    out.writeShort(0x0002);
    out.writeShort(0x0004);
    out.writeInt(0);
    out.writeInt(0);
    out.writeInt(4096);
    out.writeInt(195); /* 195 for LINKTYPE_IEEE802_15_4 */

    out.flush();
    System.out.println("Opened pcap file " + pcapFile);
  }

  public void closePcap() throws IOException {
    out.close();
    out = null;
  }

  public void exportPacketData(byte[] data) throws IOException {
    if (out == null) {
      /* pcap file never set, open default */
      openPcap(null);
    }
    try {
      /* pcap packet header */
      out.writeInt((int) (System.currentTimeMillis() / 1000));
      out.writeInt((int) ((System.currentTimeMillis() % 1000) * 1000));
      out.writeInt(data.length);
      out.writeInt(data.length);
      /* and the data */
      out.write(data);
      out.flush();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

}

@@ -93,18 +93,19 @@
 .io.File
-In
+Out
 putStrea
@@ -122,32 +122,27 @@
 java.io.
-FileOutputStream
+IOException
 ;%0Aimport
@@ -158,14 +158,8 @@
 File
-Writer
 ;%0Aim
@@ -167,78 +167,138 @@
 ort 
-java.io.IOException;%0Aimport java.io.File;%0A%0Apublic class PcapExporter %7B
+org.apache.log4j.Logger;%0A%0Apublic class PcapExporter %7B%0A  private static final Logger logger = Logger.getLogger(PcapExporter.class);
 %0A%0A  
@@ -972,26 +972,19 @@
     
-System.out.println
+logger.info
 (%22Op
@@ -1612,26 +1612,22 @@
     
-e.printStackTrace(
+logger.error(e
 );%0A 

Use logger