如何使管道使用Runtime.exec()?
String commandf = "ls /etc | grep release";try { // Execute the command and wait for it to complete Process child = Runtime.getRuntime().exec(commandf); child.waitFor(); // Print the first 16 bytes of its output InputStream i = child.getInputStream(); byte[] b = new byte[16]; i.read(b, 0, b.length); System.out.println(new String(b));} catch (IOException e) { e.printStackTrace(); System.exit(-1);}
/etc:adduser.co
poundifdef@parker:~/rabbit_test$ ls /etc | grep release lsb-release
grep
sed
偶然的你
慕姐4208626