List of usage examples for java.io File lastModified
public long lastModified()
From source file:Main.java
public static void main(String[] args) { File file = new File("Main.java"); Long lastModified = file.lastModified(); Date date = new Date(lastModified); System.out.println(date);//w w w .java 2 s . c o m }
From source file:Main.java
public static void main(String[] args) { File file = new File("C:/ReadText.txt"); System.out.println(file.lastModified()); System.out.println(file.setLastModified(new Date().getTime())); System.out.println(new Date(file.lastModified())); }
From source file:MainClass.java
public static void main(String[] args) { // Create an object that is a directory File myDir = new File("C:/Java_Dev"); System.out.println(new Date(myDir.lastModified())); }
From source file:Main.java
public static void main(String[] argv) throws Exception { File file = new File("filename"); long modifiedTime = file.lastModified(); // 0L is returned if the file does not exist long newModifiedTime = System.currentTimeMillis(); boolean success = file.setLastModified(newModifiedTime); if (!success) { // operation failed. }// w w w. j a v a2 s.co m }
From source file:Main.java
public static void main(String[] args) throws Exception { File fileToChange = new File("C:/myfile.txt"); Date filetime = new Date(fileToChange.lastModified()); System.out.println(filetime.toString()); System.out.println(fileToChange.setLastModified(System.currentTimeMillis())); filetime = new Date(fileToChange.lastModified()); System.out.println(filetime.toString()); }
From source file:Main.java
public static void main(String[] args) { File file = new File("C://FileIO//demo.txt"); System.out.println("last modifed:" + new Date(file.lastModified())); }
From source file:Main.java
public static void main(String[] args) { File dir = new File("c:\\"); File[] files = dir.listFiles(); Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR); for (int i = 0; i < files.length; i++) { File file = files[i]; System.out.printf("File %s - %2$tm %2$te,%2$tY%n= ", file.getName(), file.lastModified()); }// w w w. ja v a 2s. c o m Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE); for (int i = 0; i < files.length; i++) { File file = files[i]; System.out.printf("File %s - %2$tm %2$te,%2$tY%n= ", file.getName(), file.lastModified()); } }
From source file:FileListFilter.java
public static void main(String[] args) { File myDir = new File("C:/"); FilenameFilter select = new FileListFilter("F", "txt"); File[] contents = myDir.listFiles(select); for (File file : contents) { System.out.println(file + " is a " + (file.isDirectory() ? "directory" : "file") + " last modified on\n" + new Date(file.lastModified())); }//w w w.j av a2s .c o m }
From source file:Main.java
public static void main(String[] args) { File f = new File("c:/test.txt"); boolean bool = f.exists(); // if path exists if (bool) {//from www . jav a 2 s . c o m // 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); } }
From source file:MainClass.java
public static void main(String[] args) { File myDir = new File("C:/"); // Define a filter for java source files beginning with F FilenameFilter select = new FileListFilter("F", "java"); File[] contents = myDir.listFiles(select); if (contents != null) { System.out.println(/*from www.j a v a 2 s . co m*/ "\nThe " + contents.length + " matching items in the directory, " + myDir.getName() + ", are:"); for (File file : contents) { System.out.println(file + " is a " + (file.isDirectory() ? "directory" : "file") + " last modified on\n" + new Date(file.lastModified())); } } else { System.out.println(myDir.getName() + " is not a directory"); } return; }