Accessing files with spaces in filename from Java

This works fine for me. I do not escape them at all.

System.out.println(new File("/tmp/test 1/").exists());

Ensure you are useing the correct file separator for your operating system.

System.getProperty("file.separator")

Leave a Comment