Created
September 30, 2016 03:34
-
-
Save ron623/6992dd28ec712412d0fd1b70ca793c30 to your computer and use it in GitHub Desktop.
dateAndCalendar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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