Package com.hudong.test;
Import Java.io.File;
Import java.io.IOException;
Import java.util.ArrayList;
Import java.util.List;
Import Org.apache.commons.io.FileUtils; public class Ergodicfile {public static void main (string[] args) throws IOException {File File = new file ("
E:\\ershouok1 ");
Ergodicfile (file, 0);
Ergodicfilefolder (file);
/** * Generate Files * * @param file * @param temp * @return * @throws IOException * * public static list<file> ergodicfile (file file, int temp) throws IOException {list<file> List = new
Arraylist<file> ();
file[] filelist = File.listfiles (); for (int i = 0; i < filelist.length i++) {file Docfile = new File ("e:\\39yiyuan\\doc\\" + temp +. xml)
;
File Summaryfile = new file ("e:\\39yiyuan\\summary\\" + temp +. xml);
File ContentFile = new file ("e:\\39yiyuan\\content\\" + temp +. xml); if (Filelist[i].isfile ()) {//judgment is file if ("Doc.xml". Equals (Filelist[i].getname ()) { Fileutils.copyfile (Filelist[i], docfile); Copy file} else if ("Summary.xml". Equals (Filelist[i].getname ())) {Fileutils.copyfile (
Filelist[i], summaryfile); else if ("Content.xml". Equals (Filelist[i].getname ()) {Fileutils.copyfile (filelist[i), contentfile)
;
} else if (Filelist[i].isdirectory ()) {//Judgment is Directory Ergodicfile (Filelist[i], i);//recursive
} return list; /** * Generate files with folders * * @param file * @param temp * @return * @throws IOException * /public static list<file> ergodicfilefolder (file file) throws IOException {list<file> List = new
Arraylist<file> ();
file[] filelist = File.listfiles (); for (int i = 0; i < filelist.length; i++) {//Traverse file if (Filelist[i].isfile ()) {//judgment is file if ("Doc.xml". Equals (Filelist[i].getna
Me ()) {File Docfile = new file ("e:/yiyuan/doc/" + System.currenttimemillis ());
Docfile.mkdir ();
Fileutils.copyfile (Filelist[i], new File (Docfile.getabsolutepath () + "/doc.xml")); else if ("Summary.xml". Equals (Filelist[i].getname ()) {File ContentFile = new file ("E:/yiyuan/summa
ry/"+ system.currenttimemillis ());
Contentfile.mkdir ();
Fileutils.copyfile (Filelist[i], new File (Contentfile.getabsolutepath () + "/summary.xml")); else if ("Content.xml". Equals (Filelist[i].getname ()) {File Summaryfile = new file ("E:/yiyuan/conte
nt/"+ system.currenttimemillis ());
Summaryfile.mkdir (); Fileutils.copyfile (Filelist[i], new File (Summaryfile.getabsolutepath () + "/COntent.xml "));
} else if (Filelist[i].isdirectory ()) {//Judgment is Directory Ergodicfilefolder (Filelist[i]);//recursive
} return list;
}
}