[jcifs] How to predix password for files sharing list???

Allen, Michael B (RSCH) Michael_B_Allen at ml.com
Tue Apr 16 14:24:40 EST 2002


Use string concatenation. Perhaps something more like:

        try {
            String username = "nur";
            String password = "hotmail";
            SmbFile dir = new SmbFile( "smb://" +
                    username + ":" + password + "@192.168.42.166" );
            String[] files = file.list();
            for( int i = 0; i < files.length; i++ ) { 
                System.out.println( files[i] );
            }
        } catch( SmbAuthException sae ) {
            sae.printStackTrace();
        } catch( SmbException se ) {
            se.printStackTrace();
        }

The list() method no longer returns null (the docs are wrong). It may return an empty
String[] array though. An SmbAuthException would be thrown if a password was
wrong/not supplied. All other error conditions (i.e. "no such file or directory") are
represented by the more generic SmbException. Check out the examples in the
examples directory.

Mike

> -----Original Message-----
> From:	nur hanis [SMTP:nurhannis at hotmail.com]
> Sent:	Monday, April 15, 2002 11:28 PM
> To:	jcifs at lists.samba.org
> Subject:	[jcifs] How to predix password for files sharing list???
> 
> Hi,
> 
> Actually, I am new in jcifs. I just try the code for list the shares file 
> for certain host in network... then, how can i know the file sharing using 
> password or not???then...if it use...how can i predix the password?? 
> how..anyone can help.... here the code for list file...
> 
> **************
> SmbFile conn = new SmbFile("smb://192.168.42.166");
> String[] files = conn.list();
>     	  if( files != null ) {
>             for( int i = 0; i < files.length; i++ ) {
>                 System.out.println(files[i] );
>             }
>             System.out.println();
>         } else {
>             System.out.println( "no such file or directory" );
>      }
> 
> *************
> thanks...
> 
> _________________________________________________________________
> Join the world's largest e-mail service with MSN Hotmail. 
> http://www.hotmail.com
> 
> 





More information about the jcifs mailing list