ITPub博客

首页 > 数据库 > Oracle > 获取占用率大于70%的硬盘.java

获取占用率大于70%的硬盘.java

原创 Oracle 作者:jinqibingl 时间:2015-09-19 01:03:40 0 删除 编辑
获取占用率大于70%的硬盘,准备写入oracle过程,在占比大于90%时,向指定邮箱发送邮件。
import java.io.File;
import java.text.DecimalFormat;


public class Diskfree {
    public static void main(String[] args) {
        File[] roots = File.listRoots();
        // 获取磁盘分区列表
DecimalFormat    df   = new DecimalFormat("######0.00");   
        for (File file : roots) {
if(file.getTotalSpace()==0){
System.out.println(file.getPath()+"空的" );
     }
else
{
double free=file.getFreeSpace();
double total=file.getTotalSpace();
double usePercent=(double)free/total*100;
if(usePercent>70){String usePercent2=df.format(usePercent);
            System.out.println(file.getPath()+"盘使用率"+usePercent2+"%");}
}

        }
    }


}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9606200/viewspace-1803554/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-08-19

  • 博文量
    154
  • 访问量
    325254