473,464 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PipedOutputStream shared by java and native code?

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
Jul 17 '05 #1
1 2078
Mats Olsson wrote:
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?


From C, you can just call a Java function with a byte array as parameter.

No tweaks neccesary.

Edwin Martin.

--
http://www.bitstorm.org/
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: brian | last post by:
Hi, I've got a situation where I have a bunch of legacy code accessing a database through an archive. (Not a shared object). I've written an interface to this legacy code with C & Java using...
0
by: Naresh Agarwal | last post by:
Hi I have written a Java program, which uses JNI to talk to native C code. The java program is working well on windows, Solaris, HP-UX and Linux but it fails on AIX. On AIX (version...
0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
235
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could...
0
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
3
by: Sai Kit Tong | last post by:
I posted for help on legacy code interface 2 days ago. Probably I didn't make it clear in my original mail. I got a couple of answers but none of them address my issues directly (See attached...
3
by: Kenneth Kahl | last post by:
Hello, I would like to call a C++ programm out of Java with help of JNI. By the followed command I created a "shared library": g++ -shared -o libcalculate.so rechner.cpp When I create an...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.