[jcifs] file name is not correct

Sebastian Sickelmann sebastian.sickelmann at gmx.de
Mon Aug 15 14:59:20 MDT 2011

Am 14.08.2011 05:19, schrieb Michael B Allen:
> 2011/8/13<namadoray_curry at mail.goo.ne.jp>:
>> Hi, Mike,
>>> Try the URL escape sequence for space which is %20 like:
>> If I create SmbFile object from file name, It is OK.
>> But I want to create SmbFile object from directory.
>> 1. SmbFile dir = SmbFile("smb://host/dir/", auth);
>> 2. SmbFile[] fileList = dir.listFiles();
>> 3. execute getName, getUncPath ant getPath for each file got from fileList.
>> 4. then, I receive file name without space.
> Hi Dora,
> I believe this is occurring because of the java.net.URL class which is
> used internally to manipulate URLs. So it cannot handle some special
> characters in special instances. Meaning the java.net.URL class is
> trimming leading spaces from the filename. Unfortunately unless we
> re-write JCIFS to not use the java.net.URL class, there is not a whole
> lot we can do about this.
> Mike

Because the URL is following the recommendations in RFC2396 it tolerates 
spaces in urls and removes them. If i understand the RFC correct it is 
to make it easier for people to type in urls by hand.
Prefixing "URL:" solves it in at least for the jdk interpretation of 

So the attached patch fix it for me.

-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rfc2396.patch
Type: text/x-patch
Size: 3879 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/jcifs/attachments/20110815/5e3f4cd6/attachment.bin>

More information about the jCIFS mailing list