java获取主机磁盘信息:包括盘符,空闲,已使用等信息。
getFreeSpace()、getUsableSpace、getTotalSpace等方法都是JDK1.6 中的。
现在用JDK1.5。
本地开发测试环境Windows,服务器 Linux。
getFreeSpace()、getUsableSpace、getTotalSpace等方法都是JDK1.6 中的。
现在用JDK1.5。
本地开发测试环境Windows,服务器 Linux。
解决方案 »
- java中一个包调用另一个包出现的问题解决办法(怎么编译执行)
- 特急(求大家帮帮忙)!jdbc能够连接oralce,用hibernate无法连接。
- 求教一种网页特效!有经验的大大们来帮我看看吧
- 如何检索自动产生的关键字?
- 怎么获取文件的编码格式?
- 一个多元的Vectoer和一个executeUpdate参数的问题
- weblogic发布项目,页面无法显示
- String.format的问题
- 帮帮忙 ejb 高手请进 -------------------------- 赠送100分
- 前不久做了个云记账系统(主要为家庭记账),分享出来供大家学习。。不足之处还望指点
- db2异常:数据转换无效:参数实例 null 对于所请求的转换是无效的
- idea_ctx 是什么类型,谁见过???
if(path.length() > 2 && path.charAt(1) == ':'){
path=path.substring(0,2); // seems to make it work
}
String[] cmdAttrbs=new String[]{"cmd.exe","/C","dir /-c " + path}; BufferedReader in=null;
String line=null;
ArrayList<String> lines=new ArrayList<String>();
try{
Process proc=Runtime.getRuntime().exec(cmdAttrbs);
in=new BufferedReader(new InputStreamReader(proc.getInputStream()));
line=in.readLine();
while(line != null){
line=line.toLowerCase().trim();
lines.add(line);
line=in.readLine();
}
}
finally{
in.close();
} if(lines.size() == 0){
throw new IOException("Command line 'dir /c' did not return any info " + "for command '" + cmdAttrbs[2] + "'");
} long bytes=-1;
int i=lines.size() - 1;
int bytesStart=0;
int bytesEnd=0;
outerLoop:while(i > 0){
line=(String)lines.get(i);
if(line.length() > 0){
int j=line.length() - 1;
innerLoop1:while(j >= 0){
char c=line.charAt(j);
if(Character.isDigit(c)){
bytesEnd=j + 1;
break innerLoop1;
}
j--;
}
innerLoop2:while(j >= 0){
char c=line.charAt(j);
if(!Character.isDigit(c) && c != ',' && c != '.'){
bytesStart=j + 1;
break innerLoop2;
}
j--;
}
break outerLoop;
}
} StringBuffer buf=new StringBuffer(line.substring(bytesStart,bytesEnd));
for(int k=0;k < buf.length();k++){
if(buf.charAt(k) == ',' || buf.charAt(k) == '.'){
buf.deleteCharAt(k--);
}
}
bytes=Long.parseLong(buf.toString());
return bytes;
}
Per-process memory, cpu, credential info, state, arguments, environment, open files
File system detection and metrics
Network interface detection, configuration info and metrics
TCP and UDP connection tables
Network route tablehttp://support.hyperic.com/display/SIGAR/Home#Home-overview
比如取C盘的
freeSpaceWindows("c:")