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