Вопрос

i have a Server with several shared folders. I do not know their names, just the ipaddress. My First try with:

File rootFolder = new File(rootFolderPath);
String[] strings = rootFolder.list();

did not work.

So is there a way in java to get all shared folders on a network share?

Это было полезно?

Решение

The JCIFS SMB client library enables Java applications to remotely access shared files and directories on SMB file servers(i.e. a Microsoft Windows "share") in addition to domain, workgroup, and server enumeration of NetBIOS over TCP/IP networks.

refer 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

refer http://jcifs.samba.org/src/docs/api/jcifs/smb/SmbFile.html#list%28%29

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top