I honestly am at a loss for this. Reading & writing data from a stream without losing any information seems like a pretty basic thing you'd want to know how to do in your chosen programming language.
The reason for this is that if you're doing IO in Java you'll usually use some kind of buffered input reader rather than stdio. I've written a command line in Java that reads commands, runs native commands, streams output to the console and even that doesn't need to read stdio as a stream. It's not that Java can't do that, it's that there are better idioms for most problems.
> The reason for this is that if you're doing IO in Java you'll usually use some kind of buffered input reader rather than stdio.
The methods are the same with a buffered input reader.
> I've written a command line in Java that reads commands, runs native commands, streams output to the console and even that doesn't need to read stdio as a stream.
So, the thing that you are struggling with is how to get to System.in? But no problem doing System.out?
That's not even what the various code samples that have been posted have failed.
> It's not that Java can't do that, it's that there are better idioms for most problems.
Java's actually very good at doing IO efficiently, and as has been demonstrated, the code for this is quite simple. Sure, you wouldn't implement "cat" in Java, but you would read and write to sockets & files with it, which provides all the knowledge one might need to figure out how to solve this. As has been pointed out, the Apache Commons libraries make it so this is a two line program with no branching or looping. That's about as simple as it gets.