Java I/O – Check If File Path Absolute or not




Java Tutorial for Beginners
Java Tutorial for Beginners

In Java File class a member method isAbsolute() returns true if this abstract path name is absolute or returns false otherwise.

Lets take an example to understand the method in a better way. In this example we will construct the file path using File constructor.

/**
 * Created by codebind.com.
 */
import java.io.File;
public class Sample {
    public static void main(String[] args) {
        File myFile = new File("C:" + File.separator + "jdk" + File.separator, "FileName.java");
        System.out.println(myFile.isAbsolute());
    }
}

OUTPUT :
true

Reference:
https://docs.oracle.com/javase/7/docs/api/java/io/File.html


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





Be the first to comment

Leave a Reply

Your email address will not be published.


*