d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Stuck On Java Program > Threads/pipe/stream
Add Reply New Topic New Poll
Member
Posts: 3,193
Joined: Apr 28 2010
Gold: 242.05
Oct 19 2013 09:48pm


Im currently stuck on Q2 which is to take the stdout and stderr
and print them to console. The instuction says to make a new class to do this? but I'm stuck on how to write the class
I'm still not very versed on the concept of streams. here is what i have so far
Code
//create a new process and start it, get the relevant streams
String[] token = "java FlipFlop.java 500 1000".split("[ \t\n]+")
ProcessBuilder pb = new ProcessBuilder(token);
p = pb.start

InputStream stderr = p.getErrorStream();
InputStream sstdin = p.getInputStream();
OutputStream stdout = null;
//pass stream into PipeThread class?
PipeThread pipe = new PipeThread(stderr,stdout);


can someone give me a few pointers on how to write the PipeThread class/or if im doing something wrong so far? or better some code
snippets, will don8 fg for good pointers

This post was edited by Naiva on Oct 19 2013 09:54pm
Member
Posts: 3,193
Joined: Apr 28 2010
Gold: 242.05
Oct 20 2013 12:06am
tldr version:
"ForkFlipFlop must capture stdout and stderr from some program and print them as they are produced. "
how do i write the ForkFlipFlop class?

This post was edited by Naiva on Oct 20 2013 12:06am
Member
Posts: 3,193
Joined: Apr 28 2010
Gold: 242.05
Oct 20 2013 02:43pm
nvm figured it out had to write stream to system.out

close this please
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll