How to copy my files from one directory to another directory?

后端 未结 3 1391
梦毁少年i
梦毁少年i 2021-02-15 13:18

I am working on Android. My requirement is that I have one directory with some files, later I downloaded some other files into another directory and my intention is to copy all

3条回答
  •  悲哀的现实
    2021-02-15 13:39

    Apache FileUtils does this very simple and nicely..

    include Apache commons io package add commons-io.jar

    or

    commons-io android gradle dependancy

     compile 'commons-io:commons-io:2.4'
    

    Add this code

    String sourcePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/TongueTwister/sourceFile.3gp";
            File source = new File(sourcePath);
    
            String destinationPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/TongueTwister/destFile.3gp";
            File destination = new File(destinationPath);
            try 
            {
                FileUtils.copyFile(source, destination);
            } 
            catch (IOException e) 
            {
                e.printStackTrace();
            }
    

提交回复
热议问题