streams

Portable stream-of-bytes interface for C++

I work on an open source portable C++ image compression library. Currently, my API works by exchanging pointers to byte arrays with image data. I would like to support some kind of streaming mode for better performance and memory consumption. For this, I would like to know if there is an interface or abstract base class (part of the C+...

Downloading Image to SD Card in Service fails (Android)

I created a separate project and activity that downloads an image from a URL, converts it to a Bitmap, and then uses a FileOutputStream to save that file to the SD card. When in the separate project and free-standing activity, this worked fine, and I could see that the image is stored on the SD card. public class PictureDownload extends...

C++ overloading

The following code is giving me a compilation error. Can anyone please tell me why? class mytype { public: int value; mytype(int a) { value = a; } friend ostream& operator<<(ostream& stream, const mytype& a) { stream << a.value;//works return stream; } friend ostringstream& operator<<(ostr...

Printing Runtime exec() OutputStream to console

I am trying to get the OutputStream of the Process initiated by exec() to the console. How can this be done? Here is some incomplete code: import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.io.Reader; public class RuntimeTests { publi...

Question on streams and http request/response

When using streams, memory consumption is supposed to be the same as the size of the buffer. However, I am not sure how a stream works when I look at the following code, which uses http request and response. (HttpWebRequest to be precise) Stream requestStream = webRequest.GetRequestStream(); // Here write stuff to the stream, data is a...

Stitching together multiple streams in one Stream class

I want to make a class (let's call the class HugeStream) that takes an IEnumerable<Stream> in its constructor. This HugeStream should implement the Stream abstract class. Basically, I have 1 to many pieces of UTF8 streams coming from a DB that when put together, make a gigantic XML document. The HugeStream needs to be file-backed so tha...

Load GIF from Resource to Dynamic form.

Hi, I have this piece of code: SELDR_WH := FindControl(FindWindow(nil,'PhoneDB Filtering')) as TForm; if seldr_wh <> nil then begin SELDR_WH.ClientHeight := SELDR_WH.ClientHeight + 20; gif := TGIFImage.Create; with gif do begin Parent := SELDR_WH; Top := SELDR_WH.ClientHeight - 20; Left := 30; try ...

How do I refactor closing a stream in Java?

Due to my company's policy of using Eclipse and using Eclipse's code-autofix, the following code pattern appears excessively in the codebase: InputStream is = null; try { is = url.openConnection().getInputStream(); // ..... } catch (IOException e) { // handle error } finally { if (is != null) { try { ...

Streams usage in Java

Hello, could you please advice what Java I/O Streams can be used for? Every of them which is in standard Java 5 or Java 6 I/O API. For example FileReader and FileWriter are used for reading and writing files. StringReader and StringWriter are used for reading and writing strings in memory. ObjectInputStream and ObjectOutputStream used...

Fast controled copy from istream to ostream

I have to copy several bytes from a istream to a ostream, there are 2 ways that I know to perform this copy. myostream << myistream.rdbuf(); and copy( istreambuf_iterator<char>(myistream), istreambuf_iterator<char>(), ostreambuf_iterator<char>(myostream) ); I've found that rdbuf version is at least twice as fast as th...