Process p = null;
try {
p = new ProcessBuilder("sh").redirectErrorStream(true).start();
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("ping " + host + '\n');
os.flush();
Log.d(TAG, "Close the terminal");
// Close the terminal
os.writeBytes("exit\n");
os.flush();
Log.d(TAG, "read ping replys");
// read ping replys
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
Log.d(TAG, "while readLIne");
while ((line = reader.readLine()) != null) {
// System.out.println(line);
Log.d(TAG, "line=" + line);
}
} catch (IOException e) {
e.printStackTrace();
Log.d(TAG, "IOException=" + e);
}
댓글 없음:
댓글 쓰기