in java I call the code below:
public static void main(
String[] args) {
trancert("www.yahoo.com");
}
public static String trancert(String ip){
StringBuffer sb =new StringBuffer();
String cmdString ="tracert -h 10 ";
java.lang.Process progress = null;
BufferedReader br = null;
String s= "";
try {
progress = Runtime.getRuntime().exec(cmdString +ip);
InputStream in = progress.getInputStream();
br = new BufferedReader(new InputStreamReader(in));
while( (s =br.readLine() )!= null){
sb.append(s);
System.out.println(s);
}
} catch (IOException e) {
e.printStackTrace();
}
finally{
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
This code can be normal operation.
but in android I use String cmdString ="tracert -h 10 "; or String cmdString ="traceroute -h 10 "; it doesn't work.
I capture the Exception is "working directory:null Environment: null".
I'd like to run on all mobile phones Including no root of mobile phone.