码迷,mamicode.com
首页 > 系统相关 > 详细

通过ProcessBuilder运行linux命令

时间:2015-05-04 22:20:14      阅读:622      评论:0      收藏:0      [点我收藏+]

标签:linux android processbuilder

//String[] command = {"df", "-h", "/"}; 

//String[] command = {"df"}; 

//String[] command = {"ls"};

String[] command = {"ls","-s"} ;

StringBuilder cmdReturn = new StringBuilder();


ProcessBuilder processBuilder = new ProcessBuilder(command);

Process process = ProcessBuilder.start();


InputStream inputStream = process.getInputStream();

int c;

while ((c = inputStream.read()) != -1) {

cmdReturn.append((char)c);

通过ProcessBuilder运行linux命令

标签:linux android processbuilder

原文地址:http://laocai.blog.51cto.com/10020033/1641875

(1)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!