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;
//License from project: Open Source License 

import java.io.*;

public class Main {
    public static void touch(File file) throws IOException {
        long timestamp = System.currentTimeMillis();
        touch(file, timestamp);//from w  ww  .j ava  2  s  .  c  om
    }

    private static void touch(File file, long timestamp) throws IOException {
        if (!file.exists()) {
            new FileOutputStream(file).close();
        }
        if (!file.setLastModified(timestamp)) {
            throw new IOException("Could not set last modified for " + file.getName());
        }
    }
}

Related

  1. touch(File file)
  2. touch(File file)
  3. touch(File file)
  4. touch(File file)
  5. touch(File file)
  6. touch(File file)
  7. touch(File file)
  8. touch(File file)
  9. touch(File file)