commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pawson, David" <>
Subject RE: fileupload issue
Date Tue, 09 Nov 2004 09:28:08 GMT

    -----Original Message-----
    From: Pelle Nilsson

Hi Pelle.
    "Pawson, David" <> writes:
    > Given a windows file, with a name containing spaces 'my 
    > documents/file.ext' I'm presuming Linux may well cough at 
    > 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.

	String fileName = fn;
	if (fileName.indexOf(" ") != -1){
	    fileName =fileName.replace(' ','_');
	File uploadedFile = new File(AreaDir +sd.pathsep +fileName); // was fn

Then just use the 

(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.


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


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message