ASP源码.NET源码PHP源码JSP源码JAVA源码DELPHI源码PB源码VC源码VB源码Android源码
当前位置:首页 >> 低调看直播体育app软件下载 >> Android开发 >> Android java代码中如何执行shell命令

Android java代码中如何执行shell命令

来源:网络整理     时间:2015-09-01     关键词:

本篇文章主要介绍了"Android java代码中如何执行shell命令",主要涉及到方面的内容,对于Android开发感兴趣的同学可以参考一下: public void execCommand(String command) throws IOException { Runtime runt...

public void execCommand(String command) throws IOException {
        Runtime runtime = Runtime.getRuntime();
        Process proc = runtime.exec(command);

        try {
            if (proc.waitFor() != 0) {
                System.err.println("exit value = " + proc.exitValue());
            }
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    proc.getInputStream()));
            StringBuffer stringBuffer = new StringBuffer();
            String line = null;
            while ((line = in.readLine()) != null) {
                stringBuffer.append(line+"-");
            }
            System.out.println(stringBuffer.toString());
 
        } catch (InterruptedException e) {
            System.err.println(e);
        }
    }

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了Android java代码中如何执行shell命令,包括了方面的内容,希望对Android开发有兴趣的朋友有所帮助。

本文网址链接:http://www.codes51.com/article/detail_167856.html

相关图片

相关文章