2017-03-03 1 views
-1

다른 형식의 파일이 들어있는 폴더에서 모든 .mp3 파일을 다른 음악 폴더로 복사하려고합니다. 코드를 작성했지만 작동하지 않습니다. 어떻게하는지.하나의 폴더에서 다른 폴더로 .mp3 파일을 복사합니다.

public static void main(String[] args) { 
    File src=new File("C:\\Users\\RakeshS\\Downloads\\.mp3"); 
    File dest=new File("C:\\Users\\RakeshS\\Music"); 
    String content="C:\\Users\\RakeshS\\Downloads\\.mp3"; 
    try{ 
      Files.write(Paths.get("C:\\Users\\RakeshS\\Music"), content.getBytes(), StandardOpenOption.CREATE); 
    }catch(IOException e) 
    { 
     System.out.println(e); 
    } 
} 
+5

가능한 복제 [한 장소에서 또 다른 장소로 파일을 복사하는 방법?] (http://stackoverflow.com/questions/16433915/how-to-copy-file-from-one-location-to -another-location) – DimaSan

+0

힌트 : mp3 파일의 목록을 가져 와서 (File.listFiles()를보고, 하나씩 복사하십시오.) 일을하려는 방식대로 일괄 적으로 수행 할 수 없습니다. –

+0

FilenameUtils를 사용하여 복사하거나 건너 뛰고 자하는 확장자인지 확인하십시오. – Zeromus

답변

0

사용하면됩니다.

Files.copy(src, dest, REPLACE_EXISTING); 
관련 문제