PipedOutputStream shared by java and native code?

From: Mats Olsson (nospam_at_nodomain.com)
Date: 10/03/04


Date: Sun, 03 Oct 2004 14:52:44 GMT

I have a native process (written in c) which generates an unknown number of
bytes (jpeg images), and I would like to find an efficient way of
transferring these bytes from native to java, the end goal being a java
BufferedImage.

The overall process is run from java, and the native part is started through
a jni method call.

One idea that I have is to create a PipedOutputStream, pass it to the native
code, let the native code write its output into it, and then, in java, read
the bytes from the connected PipedInputStream.

Would this work? Or are there better alternatives in java.nio (channels,
direct buffers...) or elsewhere?

Any suggestions would be appreciated.

/Mats Olsson



Relevant Pages

  • Re: PipedOutputStream shared by java and native code?
    ... > I have a native process which generates an unknown number of ... > bytes (jpeg images), and I would like to find an efficient way of ... > transferring these bytes from native to java, the end goal being a java ... > code, let the native code write its output into it, and then, in java, read ...
    (comp.lang.java)
  • Re: encoding problem with environment variables
    ... since we don't need to access the environment variables from ... > a Java program, but rather from a native process that is spawned from ... > If you skip Runtime.execand create a native process yourself (using ...
    (comp.lang.java.programmer)
  • Re: encoding problem with environment variables
    ... since we don't need to access the environment variables from ... a Java program, but rather from a native process that is spawned from ... If you skip Runtime.execand create a native process yourself (using ...
    (comp.lang.java.programmer)
  • Re: newbie question: how to make a malloc substitute threadsafe
    ... What if the java threading model somehow makes its own context switch ... Should the native code use JNI functions MonitorEnter and MonitorExit, ... # or use the native thread synchronization primitives in the host environment ...
    (comp.programming.threads)
  • Re: Is Java for Palm/PocketPC/Zaurus a solution
    ... Palm has licensed IBM's WME ... but I believe the market has shifted somewhat. ... > a viable Java platform's not available. ... time I could have bought a pda and written my app in native code :-) ...
    (comp.lang.java.programmer)