- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the String representation of the current File object in Java
The string representation of the current file object can be obtained using the method java.io.File.toString(). This method returns the abstract path name in the string form.
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:" + File.separator + "jdk11.0.2" + File.separator, "demo1.java"); System.out.println("File: " + file.toString()); } }
The output of the above program is as follows −
Output
File: C:/jdk11.0.2/demo1.java
Now let us understand the above program.
The abstract path name is printed in the string form using the method java.io.File.toString(). A code snippet that demonstrates this is given as follows −
File file = new File("C:" + File.separator + "jdk11.0.2" + File.separator, "demo1.java"); System.out.println("File: " + file.toString());
- Related Articles
- How to get the string representation of numbers using toString() in Java?
- Python Pandas - Format the string representation of the PeriodIndex object
- Display the length of current file in Java
- String representation of Boolean in Java
- Java Program to get the File object with the absolute path for the directory or file
- Python Pandas - Format and return the string representation of the Period object
- How to get the current open file line in Python?
- Get the Current Working Directory in Java
- Get the name of the file and path in Java
- FabricJS – How to remove the current object transform in the URL string of a Line object?
- Convert the value of the current DateTime object to a Windows file time in C#
- Get the capacity of the StringBuffer Object in Java
- How to get the current date in Java?
- How to remove current object transform in the URL string of IText object using FabricJS?
- How to remove current object shadow in the URL string of IText object using FabricJS?

Advertisements