Files in the original folder: Epub/html/txt
Import Java.io.file;import Java.io.fileinputstream;import Java.io.filenotfoundexception;import Java.io.fileoutputstream;import java.io.ioexception;/** * Copy all files in the folder that contain the. epub Suffix * @author fibre * Parameter SUFFIX = ". Epu B "*/public class Copyfilefolder {private static String SUFFIX =". epub ";p ublic void CopyFolder (String folder, String NEWP Ath) throws ioexception{file old = new File (folder); file[] Filearray = Old.listfiles (); for (File File:filearray) {if (File.isfile ()) {if (File.getname (). EndsWith (SUFFIX)) { Determine if the destination folder File newpathfile = new File (NewPath), if (!newpathfile.isdirectory ()) {newpathfile.mkdirs ();} Start copying try {fileinputstream ins = new FileInputStream (file); FileOutputStream out = new FileOutputStream (newpath+ "/" +file.getname ()); SYSTEM.OUT.PRINTLN ("!! File copy: "+file.getabsolutepath () +"-----> "+newpath+"/"+file.getname ()); byte[] B = new byte[1024 * 5];int Len;while (( Len=ins.read (b))! =-1) {out.write (b);} Ins.close (); Out.close ();} catch (FileNotFoundException e) {//TODO auto-generated CatCH Blocke.printstacktrace ();}}} if (File.isdirectory ()) {CopyFolder (File.getabsolutepath (), newpath+ "/" +file.getname ()); System.out.println ("" Folder Copy ":" +file.getabsolutepath () + "----->" +newpath+ "/" +file.getname ())}}} public static void Main (string[] arg) throws ioexception{//can be changed to copy a file with a suffix of html//copyfilefolder.suffix = ". htm L "; String folder = "f://resource/to/epub/know each professional answer collection"; String target = "f://resource//epub/know each Professional answer collection (epub)"; Copyfilefolder copy = new Copyfilefolder (); Copy.copyfolder (Folder,target);}}
after execution: store by folder, only epub file