Read file with whitespace in its path using Java

后端 未结 4 829
春和景丽
春和景丽 2020-12-03 18:42

I am trying to open files with FileInputStream that have whitespaces in their names.

For example:

String fileName = \"This is my file.txt\";
String          


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 19:10

    Looks like you have a problem rather with the file separator than the whitespace in your file names. Have you tried using

    System.getProperty("file.separator")
    

    instead of your '/' in the path variable?

提交回复
热议问题