Tabnine Logo
File.lastModified
Code IndexAdd Tabnine to your IDE (free)

How to use
lastModified
method
in
java.io.File

Best Java code snippets using java.io.File.lastModified (Showing top 20 results out of 24,660)

Refine searchRefine arrow

  • File.<init>
  • File.exists
  • File.getName
  • File.length
  • File.isDirectory
  • File.getAbsolutePath
origin: redisson/redisson

public static boolean isOlder(File file, long timeMillis) {
  if (!file.exists()) {
    return false;
  }
  return file.lastModified() < timeMillis;
}
origin: gocd/gocd

public PluginFileDetails(File plugin, boolean bundledPlugin) {
  this.pluginFile = plugin;
  this.bundledPlugin = bundledPlugin;
  pluginFileName = plugin.getName();
  lastModified = plugin.lastModified();
}
origin: apache/flume

public FileInfo(File file, EventDeserializer deserializer) {
 this.file = file;
 this.length = file.length();
 this.lastModified = file.lastModified();
 this.deserializer = deserializer;
}
origin: commons-io/commons-io

name         = file.getName();
exists       = file.exists();
directory    = exists && file.isDirectory();
lastModified = exists ? file.lastModified() : 0;
length       = exists && !directory ? file.length() : 0;
origin: robolectric/robolectric

@Override
public <T extends Serializable> T load(String id, Class<T> type) {
 try {
  File file = new File(dir, id);
  if (!file.exists() || (validTime > 0 && file.lastModified() < new Date().getTime() - validTime)) {
   return null;
  }
  try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(file))) {
   Object o = in.readObject();
   return o.getClass() == type ? (T) o : null;
  }
 } catch (IOException | ClassNotFoundException e) {
  return null;
 }
}
origin: CarGuo/GSYVideoPlayer

static void setLastModifiedNow(File file) throws IOException {
  if (file.exists()) {
    long now = System.currentTimeMillis();
    boolean modified = file.setLastModified(now); // on some devices (e.g. Nexus 5) doesn't work
    if (!modified) {
      modify(file);
      if (file.lastModified() < now) {
        // NOTE: apparently this is a known issue (see: http://stackoverflow.com/questions/6633748/file-lastmodified-is-never-what-was-set-with-file-setlastmodified)
        HttpProxyCacheDebuger.printfWarning("Last modified date {} is not set for file {}", new Date(file.lastModified()).toString() + "\n" + file.getAbsolutePath());
      }
    }
  }
}
origin: stackoverflow.com

 File file = new File(filePath);
Date lastModDate = new Date(file.lastModified());
Log.i("File last modified @ : "+ lastModDate.toString());
origin: apache/storm

/**
 * Deletes jar files in dirLoc older than seconds.
 *
 * @param dirLoc  the location to look in for file
 * @param seconds how old is too old and should be deleted
 */
@VisibleForTesting
public static void cleanInbox(String dirLoc, int seconds) {
  final long now = Time.currentTimeMillis();
  final long ms = Time.secsToMillis(seconds);
  File dir = new File(dirLoc);
  for (File f : dir.listFiles((file) -> file.isFile() && ((file.lastModified() + ms) <= now))) {
    if (f.delete()) {
      LOG.info("Cleaning inbox ... deleted: {}", f.getName());
    } else {
      LOG.error("Cleaning inbox ... error deleting: {}", f.getName());
    }
  }
}
origin: org.apache.ant/ant

/**
 * Scans the directory looking for source files to be compiled.
 * The results are returned in the class variable compileList
 * @param srcDir the source directory.
 * @param dest   the destination directory.
 * @param mangler the jsp filename mangler.
 * @param files   the file names to mangle.
 */
protected void scanDir(File srcDir, File dest, JspMangler mangler,
            String[] files) {
  long now = Instant.now().toEpochMilli();
  for (String filename : files) {
    File srcFile = new File(srcDir, filename);
    File javaFile = mapToJavaFile(mangler, srcFile, srcDir, dest);
    if (javaFile == null) {
      continue;
    }
    if (srcFile.lastModified() > now) {
      log("Warning: file modified in the future: " + filename,
        Project.MSG_WARN);
    }
    if (isCompileNeeded(srcFile, javaFile)) {
      compileList.addElement(srcFile.getAbsolutePath());
      javaFiles.addElement(javaFile);
    }
  }
}
origin: apache/kylin

@Override
protected RawResource getResourceImpl(String resPath) throws IOException {
  File f = file(resPath);
  if (f.exists() && f.isFile()) {
    if (f.length() == 0) {
      logger.warn("Zero length file: {}. ", f.getAbsolutePath());
    }
    return new RawResource(resPath, f.lastModified(), new FileInputStream(f));
  } else {
    return null;
  }
}
origin: geoserver/geoserver

public Watch(File file, String path) {
  this.file = file;
  this.path = path;
  this.exsists = file.exists();
  this.last = exsists ? file.lastModified() : 0;
  if (file.isDirectory()) {
    contents = file.listFiles();
  }
}
origin: stackoverflow.com

manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
JarOutputStream target = new JarOutputStream(new FileOutputStream("output.jar"), manifest);
add(new File("inputDirectory"), target);
target.close();
try
 if (source.isDirectory())
    name += "/";
   JarEntry entry = new JarEntry(name);
   entry.setTime(source.lastModified());
   target.putNextEntry(entry);
   target.closeEntry();
 entry.setTime(source.lastModified());
 target.putNextEntry(entry);
 in = new BufferedInputStream(new FileInputStream(source));
origin: apache/hive

static void writeFile(long templateTime, String outputDir, String classesDir,
   String className, String str) throws IOException {
 File outputFile = new File(outputDir, className + ".java");
 File outputClass = new File(classesDir, className + ".class");
 if (outputFile.lastModified() > templateTime && outputFile.length() == str.length() &&
   outputClass.lastModified() > templateTime) {
  // best effort
  return;
 }
 writeFile(outputFile, str);
}
origin: plantuml/plantuml

public static Defines createWithFileName(File file) {
  if (file == null) {
    throw new IllegalArgumentException();
  }
  final Defines result = createEmpty();
  result.overrideFilename(file.getName());
  result.environment.put("filedate", new Date(file.lastModified()).toString());
  // result.environment.put("filename", file.getName());
  // result.environment.put("filenameNoExtension", nameNoExtension(file));
  result.environment.put("dirpath", file.getAbsoluteFile().getParentFile().getAbsolutePath().replace('\\', '/'));
  return result;
}
origin: eclipse-vertx/vert.x

private void addFileToWatchedList(File file) {
 filesToWatch.add(file);
 Map<File, FileInfo> map = new HashMap<>();
 if (file.isDirectory()) {
  // We're watching a directory contents and its children for changes
  File[] children = file.listFiles();
  if (children != null) {
   for (File child : children) {
    map.put(child, new FileInfo(child.lastModified(), child.length()));
    if (child.isDirectory()) {
     addFileToWatchedList(child);
    }
   }
  }
 } else {
  // Not a directory - we're watching a specific file - e.g. a jar
  map.put(file, new FileInfo(file.lastModified(), file.length()));
 }
 fileMap.put(file, map);
}
origin: apache/ignite

/**
 * Create log file for given file.
 *
 * @param file Log file.
 */
public VisorLogFile(File file) {
  this(file.getAbsolutePath(), file.length(), file.lastModified());
}
origin: iBotPeaches/Apktool

public static long recursiveModifiedTime(File file) {
  long modified = file.lastModified();
  if (file.isDirectory()) {
    File[] subfiles = file.listFiles();
    for (int i = 0; i < subfiles.length; i++) {
      long submodified = recursiveModifiedTime(subfiles[i]);
      if (submodified > modified) {
        modified = submodified;
      }
    }
  }
  return modified;
}
origin: apache/storm

  /**
   * Build mocked File object with given (or default) attributes for a file.
   */
  public File build() {
    File mockFile = mock(File.class);
    when(mockFile.getName()).thenReturn(fileName);
    when(mockFile.lastModified()).thenReturn(mtime);
    when(mockFile.isFile()).thenReturn(true);
    try {
      when(mockFile.getCanonicalPath()).thenReturn("/mock/canonical/path/to/" + fileName);
    } catch (IOException e) {
      // we're making mock, ignoring...
    }
    when(mockFile.length()).thenReturn(length);
    return mockFile;
  }
}
origin: libgdx/libgdx

/** @return true if the output file does not yet exist or its last modification date is before the last modification date of
 *         the input file */
static public boolean isModified (String input, String output, String packFileName, Settings settings) {
  String packFullFileName = output;
  if (!packFullFileName.endsWith("/")) {
    packFullFileName += "/";
  }
  // Check against the only file we know for sure will exist and will be changed if any asset changes:
  // the atlas file
  packFullFileName += packFileName;
  packFullFileName += settings.atlasExtension;
  File outputFile = new File(packFullFileName);
  if (!outputFile.exists()) {
    return true;
  }
  File inputFile = new File(input);
  if (!inputFile.exists()) {
    throw new IllegalArgumentException("Input file does not exist: " + inputFile.getAbsolutePath());
  }
  return isModified(inputFile, outputFile.lastModified());
}
origin: jfinal/jfinal

public StringBuilder getContent() {
  File file = new File(finalFileName);
  if (!file.exists()) {
    throw new RuntimeException("File not found : " + finalFileName);
  }
  
  // 极为重要,否则在开发模式下 isModified() 一直返回 true,缓存一直失效(原因是 lastModified 默认值为 0)
  this.lastModified = file.lastModified();
  
  return loadFile(file, encoding);
}
 
java.ioFilelastModified

Javadoc

Returns the time when this file was last modified, measured in milliseconds since January 1st, 1970, midnight. Returns 0 if the file does not exist.

Popular methods of File

  • <init>
    Creates a new File instance by converting the givenfile: URI into an abstract pathname. The exact fo
  • exists
    Tests whether the file or directory denoted by this abstract pathname exists.
  • getAbsolutePath
    Returns the absolute pathname string of this abstract pathname. If this abstract pathname is already
  • getName
    Returns the name of the file or directory denoted by this abstract pathname. This is just the last n
  • isDirectory
  • mkdirs
  • delete
    Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a director
  • listFiles
    Returns an array of abstract pathnames denoting the files and directories in the directory denoted b
  • getParentFile
    Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not
  • getPath
    Converts this abstract pathname into a pathname string. The resulting string uses the #separator to
  • isFile
  • length
    Returns the length of the file denoted by this abstract pathname. The return value is unspecified if
  • isFile,
  • length,
  • toURI,
  • createTempFile,
  • createNewFile,
  • toPath,
  • mkdir,
  • toString,
  • getCanonicalPath

Popular in Java

  • Running tasks concurrently on multiple threads
  • findViewById (Activity)
  • setRequestProperty (URLConnection)
  • getSharedPreferences (Context)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • JLabel (javax.swing)
  • JOptionPane (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now