Skip to main content

Posts

Showing posts with the label io

C++ - inheriting ostream crashes on android but not windows

I have implemented a simple ostream and streambuf class. For some reason, it crashes when I try to instantiate my AndroidLogOStream object. Note: I have stlport_static in my Application.mk class AndroidLogStreamBuf : public std::streambuf { public: inline AndroidLogStreamBuf() : std::streambuf() { //std::cout << "asdfg"; } inline ~AndroidLogStreamBuf() { } }; class AndroidLogOStream : public std::ostream { public: inline AndroidLogOStream() : std::ostream(&mBuf) { } inline ~AndroidLogOStream() { } private: AndroidLogStreamBuf mBuf; }; It's barebones, and it runs fine on windows. It compiles fine on android, but it crashes for some reason. The last line it tries to execute is in _streambuf.c:46: template <class _CharT, class _Traits> locale basic_streambuf<_CharT, _Traits>::pubimbue(const locale&

Can I demultiplex streams?

I want to join stderr ( getErrorStream ) and stdout ( getInputStream ) of a Process into a single Stream to be consumed elsewhere. Is there anything in Java's library that will do that for me? Note: no external libraries . I'm not interested in the existence of a solution provided by, say, Apache Commons IO. I only want to know if there's something that comes with JDK.