问题描述
如何列出特定IP地址下所有可用的共享文件夹?
模拟代码:
IP ip = new IP(10.0.0.9); (文件共享:ip.getSharedFolders){
System.out.println(share.getName());
}
有没有一种方法可以实现这一点?
我想制作类似于windows网络资源管理器的东西,我需要获取特定IP下的所有共享文件夹,所以我可以生成一个树。
第一级共享文件夹,我可以轻松地得到这样的较低级别(/ /文件f:新的文件(/ / 10.0)。 0.9 / d)。listFiles()){
System.out.println(f.getName());
您可以使用,特别是方法。这里是一个如何使用这个API的小例子:
SmbFile server = new SmbFile(smb:// server / );
String [] shares = server.list();
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.getSharedFolders){
System.out.println(share.getName());
}
Is there a way in which this can be accomplished?
I want to make something similar to windows network explorer and I need to get all the shared folders under a specific IP so I can ggenerate a tree.
With the first level shared folders I can easely get the lower levels like this
for(File f : new File("//10.0.0.9/d").listFiles()){
System.out.println(f.getName());
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();
这篇关于根据知识产权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!