我有一个具有多个共享文件夹的服务器。我不知道他们的名字,只是ipaddress。 我第一次尝试用:获取远程服务器上的所有共享目录
File rootFolder = new File(rootFolderPath);
String[] strings = rootFolder.list();
没有工作。
那么有没有办法在Java中获取网络共享上的所有共享文件夹?
我有一个具有多个共享文件夹的服务器。我不知道他们的名字,只是ipaddress。 我第一次尝试用:获取远程服务器上的所有共享目录
File rootFolder = new File(rootFolderPath);
String[] strings = rootFolder.list();
没有工作。
那么有没有办法在Java中获取网络共享上的所有共享文件夹?
除了TCP/IP网络上的NetBIOS的域,工作组和服务器枚举之外,JCIFS SMB客户端库还允许Java应用程序远程访问SMB文件服务器上的共享文件和目录(即Microsoft Windows“共享”)。
参阅http://jcifs.samba.org/src/docs/api/
public java.lang.String[] list()
throws SmbException
List the contents of this SMB resource. The list returned by this method will be;
files and directories contained within this resource if the resource is a normal disk file directory,
all available NetBIOS workgroups or domains if this resource is the top level URL smb://,
all servers registered as members of a NetBIOS workgroup if this resource refers to a workgroup in a smb://workgroup/ URL,
all browseable shares of a server including printers, IPC services, or disk volumes if this resource is a server URL in the form smb://server/,
or null if the resource cannot be resolved.
Returns:
A String[] array of files and directories, workgroups, servers, or shares depending on the context of the resource URL
Throws:
SmbException
参阅http://jcifs.samba.org/src/docs/api/jcifs/smb/SmbFile.html#list%28%29
试过这个。返回0 SMB中的文件/目录 – jussi 2012-02-09 12:52:00
http://stackoverflow.com/questions/3830847/how-to-get-all-the-shared-folders-in-windows-xp- using-java – 2012-02-09 12:43:31
共享文件夹是否与您的代码具有相同的操作系统? – 2012-02-09 12:45:00
不要这样想。 我在窗户上,这是一个NAS – jussi 2012-02-09 12:51:47