Here you can find the source of setTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime createTime, Path... files)
Parameter | Description |
---|---|
lastModifiedTime | Can be null |
lastAccessTime | Can be null |
createTime | Can be null |
files | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static final void setTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime createTime, Path... files) throws IOException
//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); } } }