这是我得到的错误:
java.lang.UnsupportedOperationException:此代码永远不会包含在pcap4j-core.jar中。
这是代码。
/ ** * * / 包com.rs.sample.network;
import java.io.IOException;
import org.pcap4j.core.NotOpenException;
import org.pcap4j.core.PacketListener;
import org.pcap4j.core.PcapHandle;
import org.pcap4j.core.PcapNativeException;
import org.pcap4j.core.PcapNetworkInterface;
import org.pcap4j.core.PcapNetworkInterface.PromiscuousMode;
import org.pcap4j.packet.Packet;
import org.pcap4j.util.NifSelector;
import com.rs.sample.IExample;
/**
* @author rahuls29
*
*/
public class NetworkLogs implements IExample {
/**
*
*/
public NetworkLogs() {
// TODO Auto-generated constructor stub
}
/*
* (non-Javadoc)
*
* @see com.rs.sample.IExample#start()
*/
public boolean start() {
// The code we had before
PcapNetworkInterface device = getNetworkDevice();
System.out.println("You chose: " + device);
// New code below here
if (device == null) {
System.out.println("No device chosen.");
System.exit(1);
}
// Open the device and get a handle
int snapshotLength = 65536; // in bytes
int readTimeout = 50; // in milliseconds
final PcapHandle handle;
try {
handle = device.openLive(snapshotLength, PromiscuousMode.PROMISCUOUS, readTimeout);
// Create a listener that defines what to do with the received packets
PacketListener listener = new PacketListener() {
public void gotPacket(Packet packet) {
// Override the default gotPacket() function and process packet
System.out.println(handle.getTimestamp());
System.out.println(packet);
}
};
// Tell the handle to loop using the listener we created
// try {
int maxPackets = 50;
handle.loop(maxPackets, listener);
handle.close();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (PcapNativeException e) {
e.printStackTrace();
} catch (NotOpenException e) {
e.printStackTrace();
}
// Cleanup when complete
return true;
}
public PcapNetworkInterface getNetworkDevice() {
PcapNetworkInterface device = null;
try {
device = new NifSelector().selectNetworkInterface();
} catch (IOException e) {
e.printStackTrace();
}
return device;
}
}
我正在尝试使用pcap4j api从网络检索数据包,但我收到错误请帮助我正在尝试使用pcap4j api从网络检索数据包,但我正在收到错误帮助我正在尝试使用pcap4j api从网络检索数据包,但我我收到错误,请帮助我正在尝试使用pcap4j api从网络中检索数据包,但我收到错误请帮助我正在尝试使用pcap4j api从网络中检索数据包,但是我得到错误,请帮助我正在尝试使用pcap4j api从网络检索数据包,但是我正在收到错误,请帮助我正在尝试使用pcap4j api从网络中检索数据包,但我正在收到错误,请帮助我正在尝试使用pcap4j api从网络中检索数据包,我正在尝试使用pcap4j api从网络中检索数据包。但我遇到错误,请帮忙