[jcifs] How to list all computers in LAN?

Jakov giaodichdientu at gmail.com
Thu Sep 20 07:33:47 GMT 2007


Thanks a lot, Mike. Here's the correct code stuff to avoid exception:

//-----------------------[code]---------------------------------//
SmbFile[] domains;
        try {
            domains = (new SmbFile("smb://")).listFiles();
            for (int i = 0; i < domains.length; i++) {
                System.out.println(domains[i]);
                SmbFile[] servers = domains[i].listFiles();
                for (int j = 0; j < servers.length; j++) {
                    System.out.println("\t"+servers[j]);
                }
            }
        } catch (SmbException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
//------------------------[/code]----------------------------------------//

Hope it will help anyone who'd do a searching on our mailing list archive!

Best regards,
Jakov



On 9/20/07, Michael B Allen <miallen at ioplex.com> wrote:
>
> On Thu, 20 Sep 2007 09:05:23 +0700
> Jakov <giaodichdientu at gmail.com> wrote:
>
> > Hi there,
> >
> > To answer the question, how to list all computers in the LAN, many
> people
> > told me that I should use JCIFS. I checked all examples in
> jcifs-1.1.11.tgz.
> > Looks like there's a file that could help: CheckAllDC.java with
> > NbtAddress.getAllByName() function. But I couldn't make it work. The
> error
> > is "java.net.UnknownHostException" with all host I gave it.
> >
> > My LAN has many domains, each has many computers. How could I list all
> of
> > them using JCIFS? Please give me a hint.
>
> SmbFile[] domains = (new SmbFile("smb://")).listFiles();
> for (int i = 0; i < domains.length; i++) {
>         SmbFile[] servers = domains[i].listFiles();
>         for (int j = 0; j < server.length; j++) {
>                 System.out.println(server);
>         }
> }
>
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the jcifs mailing list