Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
File Path with double slash in Java
The double slash in the file path is required as to create the ’\’ character , another ‘\’ needs to be added to escape it. A program that demonstrates this is given as follows −
Example
import java.io.File;
public class Demo {
public static void main(String[] args) {
File file = new File("C:\jdk11.0.2\demo1.txt");
System.out.println(file);
}
}
The output of the above program is as follows −
Output
C:\jdk11.0.2\demo1.txt
Now let us understand the above program.
The file path of the file is provided with double slash and then it is printed. A code snippet that demonstrates this is given as follows −
File file = new File("C:\jdk11.0.2\demo1.txt");
System.out.println(file); Advertisements
