[jcifs] file name is not correct

Michael B Allen ioplex at gmail.com
Sat Aug 13 21:19:07 MDT 2011


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

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/

> 2011/08/13 (Sat) 01:38, "Michael B Allen" <ioplex at gmail.com> wrote:
>> Hi Dora,
>>
>> Try the URL escape sequence for space which is %20 like:
>>
>>   SmbFile file = new SmbFile("smb://host/dir/%20foo.txt", auth);
>>
>> Mike
>>
>> --
>> Michael B Allen
>> Java Active Directory Integration
>> http://www.ioplex.com/
>>
>> 2011/8/11  <namadoray_curry at mail.goo.ne.jp>:
>> > Hi all,
>> >
>> > I am using JCIFS version 1.3.16.
>> >
>> > Here is a file which name starts with space.
>> > When I use SmbFile#getName, SmbFile#getUncPath or SmbFile#getPath,
>> > the space of the name is deleted.
>> > I want to get the correct name.
>> > My usage is invalid?
>> > Teach me how to use JCIFS.
>> >
>> > We can not create the space file name from Windows Explorer.
>> > But, rename command can do.
>> > <Procedure>
>> > 1. create a file
>> > 2. change file name.
>> > 〓 〓# rename foo.txt " foo.txt"
>> >
>> > <Sample Source>
>> > package test;
>> >
>> > import jcifs.smb.NtlmPasswordAuthentication;
>> > import jcifs.smb.SmbFile;
>> >
>> > public class Test {
>> > 〓 〓public static void main(String[] args) {
>> > 〓 〓 〓 〓try {
>> > 〓 〓 〓 〓 〓 〓NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("xxx", "yyy", "zzz");
>> > 〓 〓 〓 〓 〓 〓SmbFile file = new SmbFile("smb://host/dir/", auth);
>> >
>> > 〓 〓 〓 〓 〓 〓SmbFile[] fileList = file.listFiles();
>> > 〓 〓 〓 〓 〓 〓for (SmbFile f : fileList) {
>> > 〓 〓 〓 〓 〓 〓 〓 〓System.out.println("name:" + f.getName());
>> > 〓 〓 〓 〓 〓 〓 〓 〓System.out.println("unc:" + f.getUncPath());
>> > 〓 〓 〓 〓 〓 〓 〓 〓System.out.println("path:" + f.getPath());
>> > 〓 〓 〓 〓 〓 〓}
>> > 〓 〓 〓 〓} catch (Exception e) {
>> > 〓 〓 〓 〓 〓 〓e.printStackTrace();
>> > 〓 〓 〓 〓}
>> > 〓 〓}
>> > }
>> >
>> > ----
>> > Dora.
>> >
>>
>


More information about the jCIFS mailing list