obtain a std::ostream from a java object?

Howdy,

I'm using SWIG to create a java wrapping of a library (DCMTK) which has methods that take a std::ostream parameter. I can certainly write C++ code that returns a std::cout or that opens a file and returns me the ostream.

However, java already has nice stream classes that can go to a file, a socket, a memory buffer, etc. I'd prefer to piggyback on that. If possible, I'd like to somehow obtain a std::ostream from one of the java stream classes, e.g. java OutputStream.

How could I accomplish that?

Thanks,

-Steve

[562 byte] By [Steve_Robbinsa] at [2007-10-3 11:16:24]
# 1

If I understand the question it appears that you think there is some possible association between a C++ stream and a java stream.

There is not.

Given that the C++ methods nicely take a stream the easist way would be to construct a custom C++ stream which is a wrapper that calls JNI methods that access java stream methods.

jschella at 2007-7-15 13:40:37 > top of Java-index,Java HotSpot Virtual Machine,Specifications...