[12] Getting and Setting the Modification Time of a File or Directory

[12] Getting and Setting the Modification Time of a File or Directory

This example gets the last modified time of a file or directory and then sets it to the current time.

				
						 File file = new File("filename"); // Get the last modified time long modifiedTime = file.lastModified(); // 0L is returned if the file does not exist // Set the last modified time long newModifiedTime = System.currentTimeMillis(); boolean success = file.setLastModified(newModifiedTime); if (!success) { // operation failed. }
				
		


|----------------------------------------------------------------------------------------|
                           版权声明  版权所有 @zhyiwww
            引用请注明来源 http://www.blogjava.net/zhyiwww   
|----------------------------------------------------------------------------------------|

你可能感兴趣的:([12] Getting and Setting the Modification Time of a File or Directory)