개발이 좋아서/Java가 좋아서

파일 복사 최적화

zoaseo 2024. 11. 27. 22:41
public static void main(String[] args) throws IOException {
    long startTime = System.currentTimeMillis();

    Path source = Path.of("temp/copy.dat");
    Path target = Path.of("temp/copy_new.dat");
    Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);

    long endTime = System.currentTimeMillis();
    System.out.println("Time taken: " + (endTime - startTime) + "ms");
}