当我在jsp中显示进程时遇到问题,我使用以下代码:
public ArrayList<String> getProcessusList(){
ArrayList<String> ss=new ArrayList<String>();
String st="";
try {
String line;
Process p = Runtime.getRuntime().exec
(System.getenv("windir") +"\\system32\\"+"tasklist.exe");
BufferedReader input =
new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
String[] se=line.split(" =\n");
for(String sd:se){ss.add(sd);}
}
input.close();
} catch (Exception err) {
err.printStackTrace();
}
return ss;
}
在jsp文件中,代码是:
<body>
ArrayList <String>processArray=p.getProcessusList();
<%for(String se:processArray){
String []s=se.split(" ");
for(String sd:s){%><%=sd %> <% }%> <br><% } %>
</body>
输出:
但我想要一种更用户友好的格式,你能帮我吗?