commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Irune Prado <>
Subject [vfs] howto resolveFile an utf-8 url encoded uri
Date Tue, 16 Oct 2012 13:34:43 GMT
Hi there!

It's the first time I use vfs so maybe it's just a common mistake but I've not been able to
make it work appropriately.
I need to fetch a webdav file so my code it's something like this:

URI inputFileUri = normalizarURI(inputFile);
FileSystemManager fsManager = VFS.getManager();
FileObject sourceFile = fsManager.resolveFile(inputFileUri.toString());
return sourceFile.getContent().getInputStream();

To the point of the third line inputFileUri's value is something like

which stands for
/irune/sinadura webdav test áéióúñ_ñ/pdf con espacios.pdf

The problem is that I get the following exception
Exception in thread "main" org.apache.commons.vfs2.FileSystemException: GET method failed

for "webdav:// webdav test
¡Ã©ióúñ_ñ/pdf con espacios.pdf".

This is due to the url being decoded with ISO-8859-1 instead of UTF-8.

I lack the proper knowledge to understand low level programing but I've reached the point
in which this URI is decoded in the file
'org.apache.commons.vfs2.provider.URIParser' method 'canonicalizePath' and it seems as if
the canonicalization doesn't do it in the utf-8 way (variable lenght).


I've fixed my problem with a normalization of the inputFileURI, making a utf-8 url decode
and then an iso-8859-1 url encode and this way vfs fetch the file correctly.

I think there may be another way of doing it but I've not been able to find it.... any tips?

Thx in advance,

Irune Prado :: (944272119)

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

View raw message