I'm trying to copy one file to another directory, but the way I am copying the file is not working when the source path has a directory with spaces in it, e.g.
/Volumes/public/Music/Directory With Spaces/01.mp3
I am using: http://commons.apache.org/io/
I can't find a way around this, any ideas?
Edit: The problem should probably be putting paths with spaces into a java.io.File object.
Try it with escaped spaces:
/Volumes/public/Music/Directory\ With\ Spaces/01.mp3
If you create a
java.io.File
object with the directory you stated, does it find it? Does it find the file (i.e.file.exists()
returnstrue
)? My thought is that you need to encode it in aFile
object, or aURI
/URL
object. However, I am not intimately familiar with the Apache IO libraries, as I tend to use the standard ones in the Java releases.If the path works with the standard Java IO libraries, then that would point to some different handling with the Apache IO libraries. If it doesn't, I would attempt to get it working with those first, and then use a
File
object to get it working fully.If you are using version 1.1, then you should be able to use '%20' to refer to a space.
Source: http://commons.apache.org/io/upgradeto1_1.html