0

I'm looking for a way to overload this function in jNetPcap:

Pcap openOffline(String fname, StringBuilder errbuf);

I want to implement it in this way:

Pcap openOffline(InputStraem stream, StringBuilder errbuf);

I have downloaded the source code but this function is a native function, how can I go to the implementation of this function and try to change it?

Amir Rossert
  • 1,003
  • 2
  • 13
  • 33

1 Answers1

0

You could declare your method as static and make a call to the original native method from within your method.

Something like

static Pcap openOffline(InputStream stream, StringBuilder errbuf) {
    String fname;
    doSomeThing(); //Extract a string from the inputstream and store it in fname
    return openOffline(fname, errbuf);
}
aMpeX
  • 57
  • 7
  • Hi, this is not what i'm looking for. What i'm trying to achieve is to AVOID saving the InputStream to a file on the disk and work directly with the InputStream. I'm trying to find a way to see how the openOffline(fname, errbuf) deals with the file and change to use the InputStream instead of the file. – Amir Rossert Oct 29 '14 at 06:50
  • I see, unfortunately, there seems to be no straight-forward way to pass an InputStream to JNI since there seems to be no corresponding JNI class. Passing as a jobject wom't give you access to it. I did a bit of googling and a tool named **JunC++ion** seems to be able to generate JNI code for InputStreams. See [here](http://codemesh.com/products/junction/) – aMpeX Oct 30 '14 at 09:03