There seems to be three identical ways to get the platform-dependent “file separator” platform-independently:
How do we decide when to use which?
Is there even any difference between them?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
System.getProperties()can be overridden by calls toSystem.setProperty(String key, String value)or with command line parameters-Dfile.separator=/File.separatorgets the separator for the default filesystem.FileSystems.getDefault()gets you the default filesystem.FileSystem.getSeparator()gets you the separator character for the filesystem. Note that as an instance method you can use this to pass different filesystems to your code other than the default, in cases where you need your code to operate on multiple filesystems in the one JVM.