/** * This implementation returns the underlying File's timestamp. * @see java.nio.file.Files#getLastModifiedTime(Path, java.nio.file.LinkOption...) */ @Override public long lastModified() throws IOException { // We can not use the superclass method since it uses conversion to a File and // only a Path on the default file system can be converted to a File... return Files.getLastModifiedTime(this.path).toMillis(); }
private Long lastModifiedMs(String path) { try { return Files.getLastModifiedTime(Paths.get(path)).toMillis(); } catch (IOException e) { log.error("Modification time of key store could not be obtained: " + path, e); return null; } }
/** * This implementation returns the underlying File's timestamp. * @see java.nio.file.Files#getLastModifiedTime(Path, java.nio.file.LinkOption...) */ @Override public long lastModified() throws IOException { // We can not use the superclass method since it uses conversion to a File and // only a Path on the default file system can be converted to a File... return Files.getLastModifiedTime(this.path).toMillis(); }
private static long getFileModDate(String path) { try { return Files.getLastModifiedTime(Paths.get(path)).toMillis(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public Date getLastModified() { try { return new Date(Files.getLastModifiedTime(file).toMillis()); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public long lastModifiedTime( File file ) { try { return Files.getLastModifiedTime( path( file ) ).toMillis(); } catch ( IOException e ) { return 0; } }
/** * This implementation returns the underlying File/Path last-modified time. */ @Override public long lastModified() throws IOException { if (this.file != null) { return super.lastModified(); } else { try { return Files.getLastModifiedTime(this.filePath).toMillis(); } catch (NoSuchFileException ex) { throw new FileNotFoundException(ex.getMessage()); } } }
private long determineCreationDate(File file, Optional<BasicFileAttributes> fileAttributes) { if (fileAttributes.isPresent()) { return fileAttributes.get().creationTime().toMillis(); } else { // Creation date is unavailable on unix based oS return file.lastModified(); } }
private synchronized void writeToFile() { try { Files.write(cacheFile, Jsons.toJson(cache).getBytes(Constants.UTF_8)); this.lastModified = Files.getLastModifiedTime(cacheFile).toMillis(); } catch (Exception e) { e.printStackTrace(); } }
public static long getLastModified( File file ) throws IOException { BasicFileAttributes basicFileAttributes = Files.readAttributes( file.toPath(), BasicFileAttributes.class ); return basicFileAttributes.lastModifiedTime().toMillis(); }
private static long getLastAccessTime(File f) throws IOException { long accessTime; try { accessTime = Files.readAttributes(f.toPath(), BasicFileAttributes.class).lastAccessTime().toMillis(); } catch (NoSuchFileException e) { throw new FileNotFoundException("File " + f + " does not exist"); } return accessTime; }
private synchronized void loadFormFile() { try { long lastModified = Files.getLastModifiedTime(cacheFile).toMillis(); if (this.lastModified < lastModified) { byte[] bytes = Files.readAllBytes(cacheFile); if (bytes != null && bytes.length > 0) { cache = Jsons.fromJson(bytes, ConcurrentHashMap.class); } this.lastModified = lastModified; } } catch (Exception e) { e.printStackTrace(); } }
public static Memory filemtime(Environment env, TraceInfo trace, String path) { Path file = Paths.get(path); try { return LongMemory.valueOf(Files.getLastModifiedTime(file).toMillis() / 1000); } catch (IOException e) { env.warning(trace, e.getMessage()); return Memory.FALSE; } catch (UnsupportedOperationException e) { return Memory.FALSE; } }
/** * This implementation returns the underlying File/Path last-modified time. */ @Override public long lastModified() throws IOException { if (this.file != null) { return super.lastModified(); } else { try { return Files.getLastModifiedTime(this.filePath).toMillis(); } catch (NoSuchFileException ex) { throw new FileNotFoundException(ex.getMessage()); } } }
public FilePropsImpl(BasicFileAttributes attrs) { creationTime = attrs.creationTime().toMillis(); lastModifiedTime = attrs.lastModifiedTime().toMillis(); lastAccessTime = attrs.lastAccessTime().toMillis(); isDirectory = attrs.isDirectory(); isOther = attrs.isOther(); isRegularFile = attrs.isRegularFile(); isSymbolicLink = attrs.isSymbolicLink(); size = attrs.size(); }
public static Memory filectime(Environment env, TraceInfo trace, String path) { Path file = Paths.get(path); try { BasicFileAttributes attributes = Files.readAttributes(file, BasicFileAttributes.class); return LongMemory.valueOf(attributes.creationTime().toMillis() / 1000); } catch (IOException e) { env.warning(trace, e.getMessage()); return Memory.FALSE; } catch (UnsupportedOperationException e) { return Memory.FALSE; } }
public static Memory fileatime(Environment env, TraceInfo trace, String path) { Path file = Paths.get(path); try { BasicFileAttributes attributes = Files.readAttributes(file, BasicFileAttributes.class); return LongMemory.valueOf(attributes.lastAccessTime().toMillis() / 1000); } catch (IOException e) { env.warning(trace, e.getMessage()); return Memory.FALSE; } catch (UnsupportedOperationException e) { return Memory.FALSE; } }
@Override public long getLastModified(final Path handle) { return Try.apply(() -> Files.getLastModifiedTime(handle).toMillis()).orElse(-1L); }
public void testTouchTime() throws IOException { Path temp = createTempFile(); assertTrue(Files.exists(temp)); Files.setLastModifiedTime(temp, FileTime.fromMillis(0)); assertEquals(0, Files.getLastModifiedTime(temp).toMillis()); MoreFiles.touch(temp); assertThat(Files.getLastModifiedTime(temp).toMillis()).isNotEqualTo(0); }