0

服务器上的文件夹挂载如下:

root@ubuntusrv:/mnt# mount -t cifs //192.168.14.12/share -o auto,user,iocharset=utf8,uid=1001,umask=000,username=john,password=smith /mnt/target

或者:

root@ubuntusrv:/mnt# mount -t cifs //192.168.14.12/share -o username=john,password=smith /mnt/target

如何在 Java Web 应用程序中检查文件夹 /mnt/target 是否已安装且现在可用?

4

2 回答 2

2

答案:

File f = new File("/mnt/target/some_existing_dir);
f.exists();

不依赖于目录内容的东西可能需要依赖本机/操作系统的代码。您始终可以执行 mount 命令并过滤输出以查明您的目录是否已挂载。

于 2012-12-14T09:10:38.937 回答
1

Better is to check the folder size, as directory into where them remote file-system is mounted exists anyway. Better to check the size if the size is more or less the expected one as mounted folder is usually large for additional storage.

Link on checking folder size:

于 2012-12-14T09:32:25.290 回答