Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.BasicFileAttributes;

public class Main {
    static void getAttributes(String pathStr) throws IOException {
        Path p = Paths.get(pathStr);
        BasicFileAttributes view = Files.getFileAttributeView(p, BasicFileAttributeView.class).readAttributes();
        System.out.println(view.creationTime() + " is the same as " + view.lastModifiedTime());
    }

    public static void main(String[] args) throws IOException {
        for (String s : args) {
            getAttributes(s);
        }
    }
}