Example usage for java.io File setLastModified

List of usage examples for java.io File setLastModified

Introduction

In this page you can find the example usage for java.io File setLastModified.

Prototype

public boolean setLastModified(long time) 

Source Link

Document

Sets the last-modified time of the file or directory named by this abstract pathname.

Usage

From source file:Main.java

public static Bitmap getBitmap(String fileName) {
    Bitmap bitmap = getBitmapFromCache(fileName);
    if (bitmap != null) {
        return bitmap;
    }/*from   w  w  w.  j  a  v a 2  s.c om*/

    // modify the file attribute
    String filePath = getStorageDirectory() + File.separator + fileName;
    File file = new File(filePath);
    long time = new Date().getTime();
    file.setLastModified(time);
    return BitmapFactory.decodeFile(filePath);
}

From source file:com.santiagolizardo.madcommander.util.io.FileOperations.java

public static boolean touch(File file) {
    long currentTime = System.currentTimeMillis();
    return file.setLastModified(currentTime);
}

From source file:org.wso2.appfactory.tests.scenarios.GitOperationsTestCase.java

public static void updateFiles(File workDir) throws IOException, XmlPullParserException {
    String[] fileExtension = { "*" };

    Collection files = FileUtils.listFiles(workDir, fileExtension, true);
    for (Object fileObj : files) {
        File file = (File) fileObj;
        file.setLastModified(new Date().getTime());
    }/*w w w . java  2 s .  co  m*/
}

From source file:Main.java

public static Bitmap getImageFromLocal(String imagePath) {
    File file = new File(imagePath);
    if (file.exists()) {
        Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
        file.setLastModified(System.currentTimeMillis());
        return bitmap;
    }//from  w  w w  .  ja  v a 2  s  .com
    return null;
}

From source file:Main.java

public static File genDiscCacheFile(Context context, String imageUri) {
    File individualCacheDir = getIndividualCacheDirectory(context);
    String fileName = String.valueOf(imageUri.hashCode());
    File file = new File(individualCacheDir, fileName);
    Long currentTime = System.currentTimeMillis();
    file.setLastModified(currentTime);
    return file;/*w  ww .j  a va  2 s .c  o m*/
}

From source file:com.eatnumber1.util.io.FileUtils.java

public static void setLastModified(@NotNull File file, long time) throws IOException {
    if (!file.setLastModified(time))
        throw new IOException("Unable to set last modified time");
}

From source file:IORoutines.java

public static void touch(File file) {
    file.setLastModified(System.currentTimeMillis());
}

From source file:jeeves.utils.IO.java

/**
 * Set lastModified time if a failure log a warning.
 * /* ww w . j a va  2  s.c om*/
 * @param file the file to set the time on
 * @param timeMillis the time in millis
 * @param loggerModule the module to log to
 */
public static void setLastModified(File file, long timeMillis, String loggerModule) {
    if (!file.setLastModified(timeMillis)) {
        Log.warning(loggerModule, "Unable to set the last modified time on: " + file.getAbsolutePath()
                + ".  Check file permissions");
    }
}

From source file:com.googlecode.jmxtrans.model.output.FileWriter.java

private static void touch(File file) throws IOException {
    new FileOutputStream(file, true).close(); // ensure file exists and it's accessible

    assert (file.setLastModified(System.currentTimeMillis()));
}

From source file:com.adaptris.core.LogHandlerTest.java

public static List<Long> createLogFiles(File dir, String prefix, int count) throws Exception {
    ensureDirectory(dir);/*from w  w w . ja va2 s. c o  m*/
    ArrayList<Long> ages = new ArrayList<Long>();
    // Shoudld give us files ranging from 9 days in the past to 1hour in the
    // past.
    for (int i = count - 1; i >= 0; i--) {
        Calendar c = Calendar.getInstance();
        c.add(Calendar.DAY_OF_YEAR, 0 - i);
        c.add(Calendar.MINUTE, -1);
        ages.add(c.getTimeInMillis());
    }
    for (Long age : ages) {
        File f = File.createTempFile(prefix, null, dir);
        f.setLastModified(age);
    }
    return ages;
}