Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String getAdbPort() throws IOException { Process process = Runtime.getRuntime().exec("getprop service.adb.tcp.port"); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); return reader.readLine(); } }