Reputation: 2283
I am building an android application and have the following problem. When I want to open a file from the sdcard using FileInputStream and if the file name contains a blank character, I get the FileNotFoundException. If there are no blank characters, everything works fine. So, if I am to open for example: "My file.ext" it raises an exception, and if the file name is "Myfile.ext" everything is fine.
Any clues on how to resolve that will be much appreciated.
Regards
Upvotes: 1
Views: 511
Reputation: 1986
You could try to let android parse a certain file and open it
File file = new File(Uri.parse(path+"file name.txt"));
FileInputStream inputStream = new FileInputStream(file);
Uri should parse your filenames correctly.
Upvotes: 0
Reputation: 34564
You will need to use an escape character to specific that there is a blank in the file name. I believe it is a '\'...
So it would be like this "my\ textfile.txt"
Upvotes: 3