Read realtime output of a command
如何从 Java 读取 shell 命令的实时输出
这是我目前所拥有的,但它在命令执行后打印:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
try { proc = Runtime.getRuntime().exec("du -d 1 /sdcard/"); InputStream inputStream = proc.getInputStream(); while ((line = bufferedReader.readLine()) != null) { |
试试这个:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
try {
proc = Runtime.getRuntime().exec("du -d 1 /sdcard/"); InputStream inputStream = proc.getInputStream(); while ((line = bufferedReader.readLine()) != null) { |
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/267498.html