Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.File;
import java.util.Date;

public class Main {
    public static void main(String[] args) {

        File f = new File("c:/test.txt");

        boolean bool = f.exists();

        // if path exists
        if (bool) {
            // returns the time file was last modified
            long millisec = f.lastModified();

            // date and time
            Date dt = new Date(millisec);

            // path
            String path = f.getPath();

            System.out.print(path + " last modified at: " + dt);
        }

    }
}