Copy all Java files under one path to another folder and rename the Jad file

Source: Internet
Author: User

The requirements are simple and the program is not difficult. After seeing the topic, I did not use eclipse for the first time, but I used the editor, and made a simple program, but realized the function.

The code is as follows:

import java.io.*;class copy{public void Copy (String srcpath, String TargetPath) throws Exception{file Srcfolder = new File (Srcpath); File Tarfolder = new file (TargetPath), if (!tarfolder.exists ()) {tarfolder.mkdirs ();} FileFilter filter = new FileFilter () {public boolean accept (file file) {if (File.getname (). EndsWith (". Java")) {return true ;} return false;}}; file[] Srcfiles = srcfolder.listfiles (filter) InputStream ins = Null;outputstream ots = Null;for (File srcfile:srcfiles) { if (srcfile.exists ()) {String fileName = srcfile.getname (); ins = new FileInputStream (srcfile); ots = New FileOutputStream ( targetpath+ "/" +filename.replace ("Java", "Jad"); int reader = -1;byte[] ReadByte = new Byte[1024];while ((reader= Ins.read (ReadByte))!=-1) {ots.write (Readbyte,0,reader);}}} if (ots!=null) {ots.close ();} if (ins!=null) {ins.close ();}} public static void Main (string[] args) {Copy obj = new Copy (); Try{obj.copy ("D:/test/test1", "D:/test/test2");} catch (Exception e) {e.printstacktrace ();}}} 

Also very humble, how to design down to detail it.

Share!

Copy all Java files under one path to another folder and rename the Jad file

Related Article

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.