Android读取外部存储卡停止Process process = Runtime.getRuntime().exec("df");
使用自己的代码执行操作外部存储卡时,能够正常操作,代码如下:Process process = Runtime.getRuntime().exec("df");
is = process.getInputStream();
isReader = new InputStreamReader(is);
bufferReader = new BufferedReader(isReader);
String strLine = null;
Pattern pattern = Pattern.compile("[/\\w-]+(s|S)(d|D)[/\\w-]*");
Matcher matcher = null;
while ((strLine = bufferReader.readLine()) != null) {
//
}
bufferReader.close();
isReader.close();
is.close();
调用第三方jar,第三方也存在读取外部存储卡文件数据,结果在结束调用第三方工具后,再次调用我们的程序读取外部存储卡数据时我们的代码就在Process process = Runtime.getRuntime().exec("df");停止了。
试了下面的代码
Process process = Runtime.getRuntime().exec(command);
StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
// kick off stderr
errorGobbler.start();
StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
// kick off stdout
outGobbler.start();
process.waitFor();
依然还是在Process process = Runtime.getRuntime().exec(command);阻塞,那位高手提供一点意见嘛
java Android 外部存储卡 Runtime.getRuntime() df
补充:Java , Eclipse