Java File Touch touch(File file)

Here you can find the source of touch(File file)

Description

touch

License

Open Source License

Declaration

public static void touch(File file) throws IOException 

Method Source Code

//package com.java2s;
//it under the terms of the GNU Affero General Public License as published by

import java.io.File;

import java.io.IOException;

public class Main {
    public static void touch(File file) throws IOException {
        touch(file, false);/*from ww  w .ja  va 2  s .  co  m*/
    }

    public static void touch(File file, boolean recursive) throws IOException {
        boolean success = false;
        if (file.exists()) {
            success = file.setLastModified(System.currentTimeMillis());
        }
        checkSuccess(success, "Cannot touch file " + file);
    }

    private static void checkSuccess(boolean success, String message) throws IOException {
        if (!success) {
            throw new IOException(message);
        }
    }
}

Related

  1. touch(File baseDir, String... segments)
  2. touch(File f)
  3. touch(File f)
  4. touch(File file)
  5. touch(File file)
  6. touch(File file)
  7. touch(File file)