Чета данни от процесен поток. По принцип изпълнявам процеса с помощта на API на Runtime.exec и получавам входния поток на процеса.
Runtime rt = Runtime.getRuntime();
process = rt.exec("C:/cygwin/home/grec.exe");
InputStream is = process.getInputStream();
След това събирам резултата от процеса като --
BufferedReader in = new BufferedReader(is);
char[] ls = new char[s.available()];
ls.read(ls);
String output = new String(ls);
Въпреки това, когато отпечатвам изходния низ, получавам --
break [loc] Add a breakpoint at [file:]line or template
callflow [val] Enable call flow tracing
next Execute the over instruction, stepping over calls
over Execute the current instruction hierarchy
Но действителният резултат е...
break [loc] Add a breakpoint at [file:]line or template
callflow [val] Enable call flow tracing
next Execute the over instruction, stepping over calls
over Execute the current instruction hierarchy
print <xpath> Print the value of an XPath expression
profile [val] Turn profiler on or off
reload Reload the script contents
run Restart the script
step Execute the next instruction, stepping into calls
verbose Turn on verbose (-v) output logging
where Show the backtrace of template calls
quit Quit debugger
Тоест, част от изхода се съкращава, но не се хвърля изключение от кода. Опитах да увелича размера на BufferedReader и също така да увелича размера на масива ls. Затруднявам се да намеря причината за това поведение. Всякакви съвети или насоки за това каква може да е причината за това ще бъдат високо оценени.
s
във вашия примерен код? И може би съм пропуснал нещо, но какво ще кажете за:OutputStream out = process.getOutputStream(); BufferedReader bufferedOut = new BufferedReader(out);
- person bpgergo   schedule 16.01.2012in.readline()
? Защо създавате char масив? - person artbristol   schedule 16.01.2012