V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  DarrenF  ›  全部回复第 1 页 / 共 1 页
回复总数  1
2019-03-05 14:33:12 +08:00
回复了 TomKate 创建的主题 Java 如何通过 Java 获取远端服务器剩余磁盘大小?
@dark3212 这个我试过 挂载出来好像不行,Java 依然只能读取本地磁盘,用 File ("\\网络路径文件夹")可以读取到网络路径文件所在磁盘剩余大小:
File win = new File("\\\\192.xxx.xxx.xxx\\share");
System.out.println(win.getPath());
System.out.println(win.getName());
System.out.println("Free space = " + (win.getFreeSpace() / (1024 * 1024)) / 1024 + "G");
// 显示 GB 大小
System.out.println("Free space = " + win.getFreeSpace());
System.out.println("Usable space = " + win.getUsableSpace());
System.out.println("Total space = " + win.getTotalSpace());
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3305 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 14:10 · PVG 22:10 · LAX 07:10 · JFK 10:10
Developed with CodeLauncher
♥ Do have faith in what you're doing.