[英]Android App crash while reading command output java.lang.StringIndexOutOfBoundsException
[英]Running linux command in Android app and reading output
如何從Android App運行linux命令並讀取輸出。 例如:檢索“ ls -lh”的輸出並在TextView中打印為文本?
嘗試這個:
try{
Process process;
process = Runtime.getRuntime().exec("ls -lh");
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
之后in
發布到您的TextView中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.