The first step: First, download the Adb1.0.32.zip, inside the content:
The second step: Unzip, copy Adb.exe, and Fastboot.exe to System32, note adbwinusbapi.dll,adbwinapi.dll These two copied to the system folder, or not open!
Step three: Open the ADB, you must use CMD, otherwise flash back; use cmd to enter ADB directly;
Fourth Step: Install Android phone driver
Fifth step: Write Java code operations adb
ImportJava.io.BufferedReader;ImportJava.io.BufferedWriter;Importjava.io.IOException;ImportJava.io.InputStreamReader;ImportJava.io.OutputStreamWriter; Public classT1 { Public Static voidMain (string[] args) {Try{Process Process= Runtime.getruntime (). EXEC ("adb shell");//adb Shell FinalBufferedWriter OutputStream =NewBufferedWriter (NewOutputStreamWriter (Process.getoutputstream ())); FinalBufferedReader InputStream =NewBufferedReader (NewInputStreamReader (Process.getinputstream ())); //It is important to pay attention to the error stream reading, otherwise it is easy to block, not get the results you want, FinalBufferedReader Errorreader =NewBufferedReader (NewInputStreamReader (Process.geterrorstream ())); NewThread (NewRunnable () {String line; Public voidrun () {System.out.println ("Listener Started"); Try { while((Line=inputstream.readline ())! =NULL) {System.out.println (line); } } Catch(IOException e) {//E.printstacktrace (); }} ). Start (); NewThread (NewRunnable () {FinalBufferedReader br =NewBufferedReader (NewInputStreamReader (system.in)); Public voidrun () {System.out.println ("Writer started"); String Line; Try { while(Line =br.readline ())! =NULL) {Outputstream.write ( line+ "\ r \ n"); Outputstream.flush (); } } Catch(IOException e) {//E.printstacktrace (); }} ). Start (); inti =process.waitfor (); System.out.println ("I=" +i); } Catch(Exception e) {e.printstacktrace (); } }}
Operation Result: Console
The instructions have been successfully executed!
Android-controlled adb shell (just starting to update)