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