1. Example:
String path="d:\\ new Folder \\2.png";
File file=new file (path);
System.out.println (File.exists ());
String path1="d:/new Folder/2.png";
File file1=new file (path);
System.out.println (File1.getabsolutepath ());
System.out.println (File1.getcanonicalpath ());
2.
The specific use can achieve access to the effect of the path, but there is a small difference between the forward slash, generally in the configuration file path, pointing to the next path as long as the use of one example: "C:/a/1.txt", and the backslash, in the configuration file path, because it has a special meaning in Java, As escape characters exist, so the specific meaning of the backslash to two for example: "C\\a\\1.txt"; here the first backslash is as an escape character, the second is the true meaning of a backslash
It is generally assumed that the function of "/" is equivalent to "\ \" in Java path generally used "/" Path in Windows General "\" Linux, Unix path generally used "/"
It's best to use "/" because Java is cross-platform. "\" (in Java code should be \ \) is a path delimiter under Windows, and Linux and Unix are "/". "/" can also be recognized under Windows. So it's better to use "/"
Java path Two ways of writing "/" and "\ \"