工具类
import android.util.Log; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class ShellTool { public String getShellResult(String shell) { String result = ""; Runtime mRuntime = Runtime.getRuntime(); try { Process mProcess = mRuntime.exec(shell); InputStream is = mProcess.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader mReader = new BufferedReader(isr); String string; Log.e("->",mReader.readLine()); while ((string = mReader.readLine()) != null) { result = result + string + "\n"; } } catch (IOException e) { e.printStackTrace(); } return result; } }
标签:shell,java,String,调用,result,io,import,android From: https://www.cnblogs.com/Frank-dev-blog/p/16818007.html