/** * Writes the current time in milliseconds to the file <code>.kiji-last-used</code> in the home * directory of the user running this tool. * * @return <code>0</code> if no errors are encountered, <code>1</code> otherwise. */ public int run() { // Get the home directory and fail if there's a problem. File homeDirectory = BentoBoxUtils.getHomeDirectory(); if (null == homeDirectory) { return 1; } // Return 0 if write was successful, 1 otherwise. return generateAndWriteTimestamp(homeDirectory) ? 0 : 1; }
/** * Writes a file containing a timestamp to the specified directory. The file will be named <code> * .kiji-last-used</code> and will contain one line, which will be the timestamp specified. . * * @param directory is where the timestamp file <code>.kiji-last-used</code> should be written. * @param timestamp to write to the file. * @throws java.io.IOException if there is a problem writing the file. */ void writeTimestamp(File directory, Long timestamp) throws IOException { File timestampFile = new File(directory, TIMESTAMP_FILE_NAME); BentoBoxUtils.writeObjectToFile(timestampFile, timestamp); }