`
04023129
  • 浏览: 159240 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

Android开发片段–JAVA执行LInux脚本

阅读更多

/*
	 * シェルスクリプトを運行
	 */
	public String exec(String command) {
		StringBuffer output = new StringBuffer();
		Log.d("exec", command);
		try {
			Process process = Runtime.getRuntime().exec(command);
			DataInputStream stdout = new DataInputStream(
					process.getInputStream());
			String line;
			while ((line = stdout.readLine()) != null) {
				output.append(line).append('\n');
			}
			process.waitFor();
		} catch (Exception e) {
			PACERUtil.setLog("JAVA-ERROR", versionOld, "SHELL ERROR", storeCD, IP, macAddress);
			finish();
		}
		return output.toString();
	}
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics