1
我想在我的android設備上調用「arp -a」,但因爲它只適用於pc - 我該如何改變這種情況?有沒有辦法來訪問一個IP地址列表,即ARP -A給你,但在Android上呢?android上的Proccess命令「arp -a」?
我的代碼是這樣的在Android設備上:
try {
Process process = Runtime.getRuntime().exec("arp -a");
process.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
int i = 0;
while (reader.ready()) {
i++;
String ip = reader.readLine();
if (i >= 4) {
ip = ip.substring(2, 15) + "\n";
}
}
} catch (IOException | InterruptedException ioe) {
ioe.printStackTrace();
}
http://stackoverflow.com/a/13647492/3410697 您需要閱讀「的/ proc /淨/ ARP」爲 –
@PedroOliveira然後我如何執行命令? –
你沒有。在android中沒有這個命令。檢查我發佈的答案。 –