简体   繁体   English

使用Java将.mp3文件从一个文件夹复制到另一个文件夹

[英]Copy .mp3 file from one folder to another folder using java

I want to copy all .mp3 files from a folder which contains other types of files too,to another music folder.I have written a code but it does not work.How to do this. 我想将所有也包含其他类型文件的文件夹中的所有.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);
    }
}

您可以使用。

Files.copy(src, dest, REPLACE_EXISTING);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM