java - br.readLine() for non terminating streams? -
i writing small utility displays list of running/stopped services.it reads console output , uses output after further processing. program hangs @ br.readline() possibly because not able find terminating character in stream. here excerpt code.
try { string mainfile=""; string temp=""; process p = runtime .getruntime() .exec(system.getenv("windir") + "\\system32\\windowspowershell\\v1.0\\" + "powershell.exe get-service | format-list name , status , displayname "); p.waitfor(); inputstream = p.getinputstream(); inputstreamreader isr = new inputstreamreader(i); bufferedreader br = new bufferedreader(isr); while ((temp = br.readline())!=null) { mainfile = mainfile + temp + "\n"; } } catch (exception err) { err.printstacktrace(); } system.out.println(mainfile);
unfortunately because of problem last syso statement never printed.any pointers solve issue ?