Use InputStreamFromOutputStream and OutputStreamToInputStream
If you want fixed memory footprint, speed and ease of use you can consider using the classes developed in this project (EasyStream):
- These classes internally use pipes, they have a fixed memory footprint (don't fill up your memory with data).
- Details of threads are hidden from the user. You don't have to deal with instantiation/start/synchronization/stop. Also exception handling and propagation is already taken care of.
- You can easily choose between many [ExecutionModel options] for instantiating new Threads (thread pool, thread per instance ...) or just don't care and get the default.
- Details of pipes are hidden. No PipedInputStream or PipedOutputStream in your code.
- The internal pipe size can be adjusted to fit your needs.
So if you like this last approach you read the tutorial and see how to use these classes.
Use Pipes
Tutorial