[jcifs] URL encoding

Talbot David chukhonets at hotmail.com
Fri Mar 8 18:04:10 EST 2002


This is my first direct posting to the list. I've been following it for a 
while and just started delving into the API.

Come up against a number of strange things with URL encodings of non-ascii 
characters. Both jcifs server and the NT server are using the same charset.

The code below doesn't give any errors but the result is wrong: it says the 
directory refered to by "smb://share/path" is empty and it isn't.It is 
recognizing that the path is correct or not (throwing file not found 
exception when the unicode path is set incorrectly.)

String path="\u3042";
String encoded = URLEncoder.encode(path);
SmbFile file = new SmbFile( "smb://share/"+encoded");
SmbFile [] files = file.listFiles();

    for( int i = 0; i < files.length; i++ ) {
       System.out.print( " " + files[i] );

Also when the non-ascii section to the path is higher up the tree jcifs 
seems to be able to recognize whether the file/directory actually exists or 
not but doesn't return any contents to the directoy. Always one file.

Other examples:
Calling isDirectory() on an SmbFile with a non-ascii section to the path 
returns true even for a file.

Calling listFile() on the same SmbFile returns one SmbFile with a 
non-existant path where the final part of the path is just repeated 

What should I look at next to see what's going on? Or should I just steer 
clear of non-ascii URLs for the time being?



Send and receive Hotmail on your mobile device: http://mobile.msn.com

More information about the jcifs mailing list