Naf*_*Kay 1 java bufferedreader
我只是想用Java执行一个进程,所以
Runtime runtime = Runtime.getRuntime();
this.process = null;
try {
this.process = runtime.exec(new String[] {
properties.getPropertyStr("ffmpegExecutable", "/usr/bin/ffmpeg"),
"-i", this.streamEntry.getSource(),
"-vcodec", "copy",
"-acodec", "copy",
this.streamEntry.getDestination()
});
} catch (IOException e) {
e.printStackTrace();
return;
}
BufferedReader stdout = new BufferedReader(???process.getOutputStream());
Run Code Online (Sandbox Code Playgroud)
我只是希望能够逐行读取过程的输出.我该怎么做呢?
BufferedReader is; // reader for output of process
String line;
// getInputStream gives an Input stream connected to
// the process standard output. Just use it to make
// a BufferedReader to readLine() what the program writes out.
is = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = is.readLine()) != null)
System.out.println(line);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7002 次 |
| 最近记录: |