Import java.io.fileinputStream; import java.io.fileoutputstream; import java.io.ioException; import java.io.inputstream;
/ ** *
Title: p> *
Description: p> *
Copyright: Copyright (c) 2002 p> *
Company: p> * @ Author yinjin * @version 1.0 * / public class fileutil {public static void RMDIRS (file path) {i (path.isfile ()) {path.delete (); return;} file [] Subs = path.listfiles ); If (subs.length == 0) {path.delete ();} else {for (INT i = 0; i Public Static Void Copy (File Src, File Destine) {Try {if (! src.exists () || src.getcanonicalPath (). Equals (Destine.getcanonicalPath ()) Return; FileInputStream Fins = New FileInputStream (src); Copy (Fins, Destine); Destine.SetLastModified (src.lastmodified ());} Catch (Exception E) {}}} public static void copy (inputstream fins, file destine) {try {ix (fins == null) return; Destine.getParentFile (). mkdirs (); fileoutputstream fos = new fileoutputstream (destine); Byte [] buf = new byte [1024]; int tentlen; while (ielen = fins.read (buf, 0, buf.length) )> 0) {Fos.write (Buf, 0, readlen);} fos.flush (); fos.close (); fins.close ();} catch (exception ex) {}} public static void Move SRC, File Destine {Try {if (! src.exists () || src.getcanonicalPath (). Equals (Destine.getcanonicalPath ()) Return;} catch (ooException EX) {} copy (src, destine); Src.delete ();} / ** * Rename file without changing the suffix * @Param fromfilename: file name to be renamed * @Param Tofilename: New file name, no suffix * / public static String rename (String fromFilename, String toFilename) {String filename = toFilename; int tail_index = fromFilename.lastIndexOf ( "."); If (! Tail_index = -1) {String tail = fromFilename.substring (tail_index); filename = toFilename Tail;} Return FileName;} / ** * Create a directory based on a given path * @Param Dest * @return successfully returns true, failed to return false * / public static boolean makedir (string dest) {boilean flag = true; try { File f = new file (dest); if (! F.mkdirs ()) {flag = false;}} catch (exception e) {E.PrintStackTrace (); flag = false;} Return flag;} / ** * testing method * @