dumpe2fs /dev/sda3这个命令在linux终端里可以获取到数据,java中获取不到
代码:
String cmd = "dumpe2fs /dev/sda3";
public List<String> Cmd(String cmd) {
List<String> cmdList = new ArrayList<>();
try {
Process process = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", cmd });
InputStreamReader ir = new InputStreamReader(process.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
String line = null;
while ((line = input.readLine()) != null) {// 输出结果
cmdList.add(line);
}
} catch (java.io.IOException e) {
System.err.println("IOException " + e.getMessage());// 捕捉异常
}
return cmdList;
}