ShellExecutor.java
1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.sitech.util;
import java.util.ResourceBundle;
/**
* 本类用于执行外部命令
*
* @author winnerbao
*
*/
public class ShellExecutor {
public static void executeCmd(String cmd) throws Exception {
Runtime rt = Runtime.getRuntime();
rt.exec(cmd);
rt.gc();
}
private static String getFileName() {
String result = "";
ResourceBundle resourceBudle = ResourceBundle.getBundle("swap");
result = resourceBudle.getString("filename");
return result;
}
private static void WriteSwap(String cmd) throws Exception {
Runtime rt = Runtime.getRuntime();
rt.exec(cmd);
rt.gc();
}
/**
* ??????????????
*
* @param unit_id
* @param kpi_id
* @param kpi_value
*/
public static void WriteSwap(String unit_id, String kpi_id, String kpi_value) {
String cmd = getFileName() + " " + unit_id + " " + kpi_id + " "
+ kpi_value.replaceAll(" ", "");
try {
System.out.println(cmd);
WriteSwap(cmd);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 标志仿
*/
public static String getWriteFlag() {
// flag
String result = "0";
ResourceBundle resourceBudle = ResourceBundle.getBundle("swap");
result = resourceBudle.getString("flag");
return result;
}
}