我想您可以使用它,但是我有点犹豫要发布它。所以我只想说:
使用此方法后果自负,不建议您使用,请勿起诉我,等等。
public static void main(String[] args) throws IOException { String[] cmd = {"/bin/bash","-c","echo password| sudo -S ls"}; Process pb = Runtime.getRuntime().exec(cmd); String line; BufferedReader input = new BufferedReader(new InputStreamReader(pb.getInputStream())); while ((line = input.readLine()) != null) { System.out.println(line); } input.close();}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)