简体   繁体   中英

How to move only zip file using java?

i want to move only zip file from one folder to another folder everyday. Here is found a simple code from Developperzone website but it only copies a known txt file.

I want to use something like *.zip

Thank you

import java.io.*;
public class CopyFile
  {
  public static void main(String args[]) throws Exception
    {
    BufferedReader br = new BufferedReader(
                        new FileReader("line.txt"));
    BufferedWriter bw = new BufferedWriter(
                        new FileWriter("linenum.txt"));
    String s, space="  ";
    int num=0;
    while (br.ready())
      {
      s=br.readLine();
      num++;
      bw.write(String.valueOf(num));
      bw.write(space);
      bw.write(s);
      bw.newLine();
      }
    bw.close();
    }
  }

Use java.io.File and its methods to get the list of .zip files and move them (Tutorial - Moving a File or Directory ).

import static java.nio.file.StandardCopyOption.*;
...
Files.move(source, target, REPLACE_EXISTING); 

Do you mean some like this in linux?

mv *.zip dest-dir

Why do you want to do this in Java?

I assume you want to move rather than copy?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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