ITeye博客

File Size

louisling · 2009-09-01 15:25 · Java · Java · F# · Markdown

public static void main(String[] args) throws IOException {
    File file = new File("F:");
    if (file.exists()) {
        prt("Total:", file.getTotalSpace());
        prt("Usable:", file.getUsableSpace());
        prt("Free:", file.getFreeSpace());
    }
}

static void prt(String desc, long size) {
    double m = size / (1024 * 1024);
    double g = m / 1024;
    System.out.printf("%s %.2f G / %.2f M %n", desc, g, m);
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。