Shares Under IP

前端 未结 3 671
故里飘歌
故里飘歌 2020-12-10 17:48

How to list all the available shared folders under a specific IP Address?

Mock code:

IP ip = new IP(\"10.0.0.9\");

for(File share : ip.getSharedFold         


        
相关标签:
3条回答
  • 2020-12-10 18:11

    You can get the list of shares using the The Java CIFS Client Library and in particular the SmbFile.list method. Here is a small illustration of how to use this API:

    SmbFile server = new SmbFile("smb://server/");
    String[] shares = server.list();
    
    0 讨论(0)
  • 2020-12-10 18:22

    Java from out of the box does not support what you are trying to do. You need to use libraries such as JCIFS to do this.

    One easy/cludgy way out though would be to make sure that you have a drive mapping ( if windows or nfs/smb mount for other OSs) to the location and then treat it as a local file - using java.io APIs.

    0 讨论(0)
  • 2020-12-10 18:28

    If the files are accessible through the server IP address (network wise and permission wise) then sure you can list them all recursively by doing the following:

    1. Get the remote folder name. Example "//10.0.0.9/folder"
    2. Iterate through that folder just as you would do to list files in a local directory (see this link to know more about listing local files in a local directory
    0 讨论(0)
提交回复
热议问题