[brailleblaster] Re: searching java reference

  • From: "qubit" <lauraeaves@xxxxxxxxx>
  • To: <brailleblaster@xxxxxxxxxxxxx>
  • Date: Fri, 10 Dec 2010 12:14:04 -0600

Mike, no need for the hose example, as I have said I have programmed this in 
C several times, complete with hooking up pipes.  The question was in the 
java docs, which, as I reread right now, do not imply that getInputStream() 
connects to the output stream of the child process.
It is documented inconsistently as the error stream does connect the stderr 
to an input stream in the parent. But the input stream appears to have input 
at both ends of the hose, and the OutputStream appears to have output at 
both ends of the hose.  (like a bad case of the flu -- sorry, couldn't 
resist...;)
Only the error stream appears to be flowing correctly.
Perhaps there is a processing step I have missed.  Is java's process control 
based on unix's fork() and exec() model?  I see there is a collection of 
exec methods.  However, there is not anything documented in the pages I am 
looking at that describe how to identify when one is in the child or parent 
process.  Perhaps hooking up pipes is still necessary.
This code is going together nicely, but I need to get past this one step.
--le

----- Original Message ----- 
From: "Michael Whapples" <mwhapples@xxxxxxx>
To: <brailleblaster@xxxxxxxxxxxxx>
Sent: Friday, December 10, 2010 6:01 AM
Subject: [brailleblaster] Re: searching java reference


I will explain this again, it reads correct to me:
InputStream getErrorStream: This is the error output from the process
you spawned, it is being read back into your Java code, therefore from
the frame of reference of the Java code data is flowing in.
InputStream getInputStream: This is standard out of the process, so
again the Java code is reading in, data flow is out of the process and
into the Java, so InputStream.
OutputStream getOutputStream: This is connected to standard in of the
process, so Java is sending data out and the process is getting data in.

Reading the human generated description of these methods in the javadoc
makes it clear to me this is what is going on.

I will try and give a different example which may help explain this flow
stuff and the direction. If I consider a water tap with a hose pipe (I
will refer to as the pipe) which has the other end of the hose pipe in a
pool. If you turn on the tap to fill the pool with water you get water
flowing along the pipe. Now answer the question is water flowing in or
out? Hopefully you will say it depends on what is being referred to, the
tap or the pool. Water is flowing out of the tap and into the pool at
the same time. So to the tap the pipe is an output and to the pool the
same pipe is input.

Now let us try and transfer this back to the problem of
java.lang.Process. Let us consider the error pipe (as this will not give
us any naming problem). Instead of water flowing the pipe we have data,
the process is able to be like the tap and output to standard error, our
controlling java application is like the pool and is getting input from
this pipe.

Now if we consider getInputStream, the human part of the javadoc does
say this relates to standard output of the spawned process, this makes
sense if the method is named for the controlling java code. The spawned
process is like the tap in the water example, it outputs to standard
output, data flows through the pipe to the java code which reads this
data  in from the pipe and yes we use InputStreams for that.

I hope now you can work out getOutputStream yourself, it doesn't feel
worth repeating what I have said.

Does the javadoc now make sense to you?

Michael Whapples
On 09/12/10 23:41, qubit wrote:
> Sina, the docs say
>
> InputStream getErrorStream();
> InputStream getInputStream();
> OutputStream getOutputStream();
>
> If I'm the parent process and just spawned this process, then the last 2
> return types should be switched as I will be writing to input and reading
> from output.
> Note that err and out are treated inconsistently.
>
> Is this a bug? Do I need to do some obscure pipe operations to get the 
> input
> and output flowing correctly? Then why was err handled differently from 
> out?
> You're a java expert, perhaps you can settle this. I am just now getting
> ready to compile my code, which should tell me if my types are mismatched.
> I'll be posting to list hopefully soon.
> TIA
> --le
>
> ----- Original Message -----
> From: "Sina Bahram"<sbahram@xxxxxxxxx>
> To:<brailleblaster@xxxxxxxxxxxxx>
> Sent: Thursday, December 09, 2010 5:11 PM
> Subject: [brailleblaster] Re: searching java reference
>
>
> The human part of javadoc can be incorrect, although I find this doubtful.
>
> However, the actual return type of the methods, as you've discussed, are 
> not
> incorrect. They might not meet expectations, but it is
> automatically generated, so I find it next to impossible for this to be
> incorrect.
>
> Take care,
> Sina
> -----Original Message-----
> From: brailleblaster-bounce@xxxxxxxxxxxxx
> [mailto:brailleblaster-bounce@xxxxxxxxxxxxx] On Behalf Of qubit
> Sent: Thursday, December 09, 2010 5:49 PM
> To: brailleblaster@xxxxxxxxxxxxx
> Subject: [brailleblaster] searching java reference
>
> Is there an easyer way to search the java reference pages by class or by
> category? I'm having a fun time playing with process and
> runtime and streams and the like, but some of the docs are indeed 
> incorrect,
> despite what Mike is saying.
> I am looking at the link you sent me about the getInputStream() etc 
> methods
> in class Process.
> Perhaps I will go look for a download link, but I don't have much space on
> my hd.
>
> I will post what I have so far shortly, but indeed I know the docs are
> wrong, because they are inconsistent.  Compiling will solve
> the dilemma.
> --le
>
>
>
>



Other related posts: