您好,登錄后才能下訂單哦!
public static String formatDate(long date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return formatter.format(date);
}
/**
* get result of command, after execute dos command
* 通過執行dos命令獲取結果
*
* @param :dos command,String
* @return List<String>
*/
public static List<String> execCmdConsole(String cmdString) {
List<String> dosRes = new ArrayList<String>();
Process process = null;
try {
LogUtil.info(cmdString);
if (osName.toLowerCase().contains("mac")) {
String[] command = {"/bin/sh", "-c", cmdString};
process = Runtime.getRuntime().exec(command);
} else if (osName.toLowerCase().contains("win")) {
process = Runtime.getRuntime().exec("cmd /c " + cmdString);
}
InputStream in = process.getInputStream();
BufferedReader inr = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = inr.readLine()) != null) {
dosRes.add(line);
}
try {
process.waitFor();
process.destroy();
} catch (InterruptedException e) {
e.printStackTrace();
}
log.debug("get result of command after execute dos command " + cmdString + " Succeed ");
} catch (IOException e) {
log.error("get result of command after execute dos command " + cmdString + " Failure", e);
}
return dosRes;
}
/**
* 獲取手機版本
*
* @return
*/
public static String getMobileModel() {
/**
* 獲取手機版本
*/
String mobileModel = "adb shell getprop ro.product.model";
String s = OperationalCmd.execReturnAndWait(mobileModel);
return s;
}
/**
* 獲取手機系統版本
* 版本號
*
* @return
*/
public static String getVersionNameInfo() {
/**
* 版本號
*/
String versionName = "adb shell dumpsys package com.jingdong.th.app | findstr versionName";
/**
* 獲取手機系統版本
*/
String versionRelease = "adb shell getprop ro.build.version.release";
List<String> devList = OperationalCmd.execCmdConsole(versionName);
String s = devList.get(0).split("=")[1] + "/Android:" + OperationalCmd.execReturnAndWait(versionRelease);
return s;
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。