我用 java 代码启动 Drozer 服务后怎样往里面输入命令得到结果

开启服务代码



public int runSH() {
        ProcessBuilder p = new ProcessBuilder("drozer.bat", "console", "connect");
        p.directory(new File("E:\\drozer"));

        int i = 0;
        try {
            Process process= p.start();

            final InputStream is1 = process.getInputStream();
            final InputStream is2 = process.getErrorStream();
            final OutputStream is3 = process.getOutputStream();
            new Thread() {
                public void run() {
                    BufferedReader br = new BufferedReader(new InputStreamReader(is1));
                    try {
                        String lineB = null;
                        while ((lineB = br.readLine()) != null) {
                            if (lineB != null)
                                System.out.println("[debug]" + lineB);
                        }

                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }.start();

            new Thread() {
                public void run() {

                    BufferedReader br2 = new BufferedReader(new InputStreamReader(is2));
                    try {
                        String lineC = null;
                        while ((lineC = br2.readLine()) != null) {
                            if (lineC != null)
                                System.out.println("[debug]" + lineC);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }.start();
            i = process.waitFor();

        } catch (Exception e) {
            System.err.println(e);
        }
        System.out.println(i);
        return i;
    }


↙↙↙阅读原文可查看相关链接,并与作者交流