Java Path Create nio setTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime createTime, Path... files)

Here you can find the source of setTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime createTime, Path... files)

Description

Set files times.

License

Open Source License

Parameter

Parameter Description
lastModifiedTime Can be null
lastAccessTime Can be null
createTime Can be null
files a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static final void setTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime createTime,
        Path... files) throws IOException 

Method Source Code

//package com.java2s;
/*//from  w  ww.j  av a  2 s .  c  om
 * Copyright (C) 2017 Timo Vesalainen <timo.vesalainen@iki.fi>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.IOException;

import java.nio.file.Files;
import java.nio.file.Path;

import java.nio.file.attribute.BasicFileAttributeView;

import java.nio.file.attribute.FileTime;

public class Main {
    /**
     * Set files times. Non null times are changed.
     * @param lastModifiedTime Can be null
     * @param lastAccessTime Can be null
     * @param createTime Can be null
     * @param files
     * @throws IOException 
     */
    public static final void setTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime createTime,
            Path... files) throws IOException {
        for (Path file : files) {
            BasicFileAttributeView view = Files.getFileAttributeView(file, BasicFileAttributeView.class);
            view.setTimes(lastModifiedTime, lastAccessTime, createTime);
        }
    }
}

Related

  1. createZipFileSystem(Path zipFile)
  2. createZipFs(Path path)
  3. createZkNodeName(String zkRoot, Path root, Path file)
  4. getOrCreateDir(Path path)
  5. isTempCreatedFile(Path filePath)
  6. toPath(@Nullable String plain)
  7. toPath(String first, String... more)
  8. toPath(String path)
  9. toPath(String uri, Path root)