Copy jar Package

Source: Internet
Author: User

 PackageCom.cici;ImportJava.io.File;ImportJava.io.FileInputStream;Importjava.util.ArrayList;Importjava.util.List;Importorg.apache.commons.io.FileUtils; Public classtestcopy {Private Staticlist<file> files =NewArrayList ();  Public Static voidMain (string[] args)throwsException {testcopy TCP=Newtestcopy (); Copyjars ("D:\\path1", "D:\\path2"); }      Public Staticstring Getfilesuffix (String STRs) {string ss[]= Strs.split ("\ \.")) ; returnSs[1]; }       Public Static voidcopyjars (String sourcedir, string destDir)throwsException {addjarsintolist (SourceDir); File File=NewFile (DestDir); if(File.isdirectory ()) { for(File f:files) {FileInputStream InputStream=NewFileInputStream (f); Fileutils.copyfile (F,NewFile (File.getpath () + "\ \" +f.getname ())); }        }      }       Public Static voidaddjarsintolist (String path1) {File dir=NewFile (path1); if(Dir.isdirectory ()) {file[] subfiles=Dir.listfiles ();  for(File file:subfiles)//if it is file and we need to added into file list            if(File.isfile ())if(Getfilesuffix (File.getname ()). Equals ("Jar") ) files.add (file); //if it is not file it's just directory then we need to analize it then it into directory            Elseaddjarsintolist (File.getabsolutepath ()); }      }}

Copy jar Package

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.