-
16. bytestream - (5) FileCopyDemo5 ( 음악파일 복사 - Buffer 사용 )java/코드 리뷰 2020. 4. 27. 16:1612345678910111213141516171819202122232425262728293031323334353637package bytestream;import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;public class FileCopyDemo5 {public static void main(String[] args) throws FileNotFoundException, IOException{System.out.println("파일 복사를 시작합니다.");long startTime = System.currentTimeMillis();FileInputStream fis = new FileInputStream("c:/files/SleepAway.mp3");FileOutputStream fos = new FileOutputStream("c:/files/sleep away.mp3");BufferedInputStream bis = new BufferedInputStream(fis);BufferedOutputStream bos = new BufferedOutputStream(fos);int value = 0;while ((value = bis.read()) != -1) {bos.write(value);}bis.close();bos.close();long endTime = System.currentTimeMillis();System.out.println("파일 복사가 종료되었습니다.");System.out.println("소요시간 : " + ((endTime - startTime) / 1000 + "초"));}}
'java > 코드 리뷰' 카테고리의 다른 글
16. bytestream - (7) FileCopyDemo7 ( 사진파일 복사 - url 사용 ) (0) 2020.04.27 16. bytestream - (6) FileCopyDemo6 ( 음악파일 복사 - IOUtils 사용 ) (0) 2020.04.27 16. bytestream - (4) FileCopyDemo4 ( 음악파일 복사 ) (0) 2020.04.27 16. bytestream - (3) FileCopyDemo3 ( 사진 복사 ) (0) 2020.04.27 16. bytestream - (2) FileCopyDemo2 ( 파일 복사 - 반복문 ) (0) 2020.04.27