-----Original Message-----
From: Pelle Nilsson
Hi
Hi Pelle.
"Pawson, David" <[EMAIL PROTECTED]> writes:
> Given a windows file, with a name containing spaces 'my
> documents/file.ext' I'm presuming Linux may well cough at
creating
> such a file.
Linux has no problem with spaces in filenames.
(Oh dear, my age is showing. It used to didn't it.. or Unix didn't, I'm sure)
A lot of us
Linux users have problems with spaces in filenames, but
that's only culture, not technology.
I guess I fall into that culture. I had to look quite hard to find a file
with spaces in the name :-)
I think Linux
filenames can include everything except for the path
separator (/) (even newlines and other strange stuff are allowed).
Martins email made me look twice. I did feel a little foolish.
//TRIAL
String fileName = fn;
if (fileName.indexOf(" ") != -1){
fileName =fileName.replace(' ','_');
}
File uploadedFile = new File(AreaDir +sd.pathsep +fileName); // was fn
Then just use the
item.write(uploadedFile);
(Now I see why Martin couldn't see the problem. There wasn't one!).
I guess a whitespace regex would be better, to account for tabs etc,
but I've proved it works though. File was uploaded and name changed.
I think I'll include the change, even if I don't need to Pelle,
just to make me feel better.
String fileName = fn;
Pattern p =Pattern.compile("[ \t]");
Matcher m = p.matcher(fileName);
if (fileName.indexOf(" ") != -1){
fileName =m.replaceAll("_");
}
regards DaveP.
--
DISCLAIMER:
NOTICE: The information contained in this email and any attachments is
confidential and may be privileged. If you are not the intended
recipient you should not use, disclose, distribute or copy any of the
content of it or of any attachment; you are requested to notify the
sender immediately of your receipt of the email and then to delete it
and any attachments from your system.
RNIB endeavours to ensure that emails and any attachments generated by
its staff are free from viruses or other contaminants. However, it
cannot accept any responsibility for any such which are transmitted.
We therefore recommend you scan all attachments.
Please note that the statements and views expressed in this email and
any attachments are those of the author and do not necessarily represent
those of RNIB.
RNIB Registered Charity Number: 226227
Website: http://www.rnib.org.uk
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]