Skip to content

Instantly share code, notes, and snippets.

@ron623
Created September 30, 2016 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ron623/6992dd28ec712412d0fd1b70ca793c30 to your computer and use it in GitHub Desktop.
Save ron623/6992dd28ec712412d0fd1b70ca793c30 to your computer and use it in GitHub Desktop.
dateAndCalendar
package dateAndCalendar;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
public class CreateDate {
public CreateDate() {
// TODO 自動生成されたコンストラクター・スタブ
}
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
// ファイルのコピー
FileSystem fs = FileSystems.getDefault();
Path path1 = fs.getPath("c:\\temp\\aaa.txt");
Path path2 = fs.getPath("c:\\temp\\test\\aaa.txt");
// ファイルのコピー(上書きOK)
try {
Files.copy(path1, path2, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
System.out.println("ファイルをコピーしました");
} catch (IOException e) {
// TODO 自動生成された catch ブロック
System.out.println("ファイルコピー失敗");
e.printStackTrace();
}
try {
Path r = Files.copy(path1, path2, StandardCopyOption.COPY_ATTRIBUTES);
System.out.println("ファイルをコピーしました");
} catch (IOException e) {
// TODO 自動生成された catch ブロック
System.out.println("ファイルコピー失敗");
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment