This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why cant I read Process input staream??  RSS feed

Yaroslav Chinskiy
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am executing a ptogram from the command prompt that outputs CPU load every second to the screen.
c:\>typeperf 1 "\Processor(0)\% Processor Time"

"Sample Time","\Processor(0)\% Processor Time"
"03/30/2001 11:14:43.843","0"
"03/30/2001 11:14:44.843","0"
"03/30/2001 11:14:45.843","0"
"03/30/2001 11:14:46.843","0"
(typeperf comes with resoure kit)
I am tried to execut the same program from Java and read its input stream and then print it to the screen.

Process prc = Runtime.getRuntime().exec("typeperf 1 \"\\Processor(0)\\% Processor Time\"");
BufferedReader in = new BufferedReader(new InputStreamReader(prc.getinputStream()));
String line = null;
while((line = in.readLine()) != null){
However instad of printing line every sec, it waits and prints bunch of line at the time.
Do you know why?
PS: tried to do the same thing in Perl. Same resoult could it be dos related issue?
Thank you.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!