Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why cant I read Process input staream??

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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic