/** * Saves the expiration date for the given file. * * @param fileName the file * @param metadata the metadata * @throws Exception if an error occurs */ public static final void saveMetadata(Path fileName, ConfigurationPartMetadata metadata) throws Exception { AtomicSave.execute( fileName.toString() + METADATA_SUFFIX, "expires", metadata.toByteArray(), StandardCopyOption.ATOMIC_MOVE); }
/** * @param fileName the file name * @return the metadata for the given file. * @throws Exception if the metadata cannot be loaded */ public static ConfigurationPartMetadata getMetadata(Path fileName) throws Exception { File file = new File(fileName.toString() + METADATA_SUFFIX); try (InputStream in = new FileInputStream(file)) { return ConfigurationPartMetadata.read(in); } }