Reputation: 5
we can use separator as "\" or "/" . And my question is is there any difference between them? For example;
new File("c:\\temp.txt");
or
new File("c:/temp.txt");
Upvotes: 0
Views: 980
Reputation: 1074148
There's a duplicate of this around somewhere, but if you use JDK methods, it doesn't matter which you use as they'll normalize them before they get to the OS. That cannot necessarily be said for other libraries. For max compatibility, use File.separator
/File.separatorChar
to get the OS-specific version. (\
on Windows, /
on just about everything else.)
Upvotes: 3