

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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);
- Related Questions & Answers
- Get Absolute path of a file in Java
- Get the path of the file selected in the JFileChooser component with Java
- Java Program to get the File object with the absolute path for the directory or file
- How to get left substring in MySQL from a column with file path? Display the entire file path string excluding the file name?
- Get the name of the file and path in Java
- Specify a path for a file or a directory in Java
- Get the absolute path for the directory or file in Java
- Get an Absolute Filename Path from a Relative Filename with Path in Java
- Double brace initialization in Java
- Double isInfinite() method in Java
- Double isNaN() method in Java
- Format double type in Java
- How to Convert Double to String to Double in Java?
- Convert double primitive type to a Double object in Java
- Java Double compare example
Advertisements