Reputation: 135992
Do we actually need to provide correct file separator in java.io.File path expression? In other words, does it make any difference to write path + File.separator + fileName
instead of path + "/" + fileName
for any OS?
Upvotes: 0
Views: 1310
Reputation: 339
It's probably that you don't know in which version of Windows will be your application and for this reason I recommend you to use always System.getProperty(file.separator);
Upvotes: 1
Reputation: 1509
I usually stick to File.seperator .
However I noticed that Java is smart enough to handle correctly "/" on any operating system.
Upvotes: 0
Reputation: 16387
Some people might say technically yes, but in practice since windows works with either \ or /, just use unix file separators and you'll be fine.
Upvotes: 2