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

后端 未结 3 1390
梦毁少年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:47

        void copyFile(File src, File dst) throws IOException {
           FileChannel inChannel = new FileInputStream(src).getChannel();
           FileChannel outChannel = new FileOutputStream(dst).getChannel();
           try {
              inChannel.transferTo(0, inChannel.size(), outChannel);
           } finally {
              if (inChannel != null)
                 inChannel.close();
              if (outChannel != null)
                 outChannel.close();
           }
        }
    

    I can't remember where I found this, but it was from a useful article I used to backup a SQLite database.

提交回复
热议问题