Reading from and writing to streams in Java is the same no matter if the stream is a file, socket or a process. You are familiar with System.out.println(), correct? The out member of System is a
PrintStream. Process gives you an
OutputStream which is pretty primitive (you can only write a single byte or an array of bytes). Rather than converting everything I want to write to bytes, I prefer to wrap the stream with a higher-level stream like PrintWriter which can write
String objects directly, like so:
Read through the Java Tutorial chapter on
Input/Output for more on working with streams.