/ ** * file copy (single) * Create date: (2002-1-24 9:52:47) * @Param from java.lang.string * @Param to java.lang.string * / public boilean copy (String From, string to) {try {to = replace (to, "//", "/"); string Topath = to.substring (0, to.lastindexof ("/")); file f = new file (Topath ); if) f.mkdirs (f.exists (!) (); BufferedInputStream bin = new BufferedInputStream (new FileInputStream (from)); BufferedOutputStream bout = new BufferedOutputStream (new FileOutputStream (to)); int c; while ((c = bin.read ())! = -1) Bout.write (c); bin.close (); bout.close (); return true;} catch (exception e) {E.PrintStackTrace (); return false; }
/ ** * Determined the file * Create Date: (2002-1-24 9:19:48) * @Return Boolean * @Param FileName Java.lang.String * / Public Boolean EXISTS (String FileName) {Try {FileReader f = new fileReader (new file (file (filename));} catch (filenotfoundexception e) {return false;}} / ** * Decompression program * Create Date: (2002-1-22 14:37:07) * @return java.util.Vector * @param strFile java.lang.String * / public void extractFile (String zipName, String path) throws Exception {ZipInputStream zin = new ZipInputStream (new FileInputStream (zipName)); ZipEntry entry; path = replace (PATH, "//", "/"); if (! path.endswith ("/")) PATH = "/"; while ((entry = zin.getnextentry ())! = null) {String Temp = entry.getname ();
BufferedInputStream Bin = New BufferedInputStream (ZIN);
File ff = new file (path); if (! Ff.exiss ()) ff.mkdirs (); string filename = path temp;
IF (filename.indexof ("/")! = -1 &&! filename.endswith ("/")) {ff = new file (filename.substring (0, filename.lastIndexof ("/") 1)); IF (! ff.exists ()) ff.mkdirs ();} ff = new file (filename); if (! filename.endswith ("/"))) {BufferedoutputStream Bout = New BuffRedOutputStream (New Fileoutputstream (FileName)); INT C; while ((c = bin.read ()))! = -1) {bout.write (c);} bout.close ();}
}
}
/ ** * Get the local absolute path of Class * Create Date: (2002-1-23 16:36:14) * @Return java.lang.string * @Param sclassname java.lang.string * / public string getlocalpath () {Try {string classname = getClass (). Getname (); string classpath = replace (classname, ".", "//"); string sysclasspath = system.getProperty ("java.class.path"); sysclasspath = replace (sysclasspath, "/"); StringTokenizer token = new StringTokenizer (sysclasspath, ";"); while (token.hasmoreElements ()) {string ele = token.nextToken (); if (ELE " //" classpath ".class ")) {if.equals (") ELE = System.getProperty ("user.dir"); string r = ele "//" ClassPath ". Class" RETURN R;}}} Catch (Exception E) {E.PrintStackTrace ();} return null;} / ** * Get a certain range of random number * Create Date: (2002-1-23 15:19:00) * @Return int * @Param Low int * @Param road int * / public static int getram (int low, int high) {if (low> high) return -1; int r; while (true) {r = (int = (Math.random () * HIGH); if (r
} / ** * Mobile file (single) * Created date: (2002-1-24 10:00:55) * @Param from java.lang.string * @Param to java.lang.string * / public boolean move String from, string to) {Try {copy (from, to); file f = new file (from); return f.delete ();} catch (Exception E) {E.PrintStackTrace (); return false;}} / ** * Replacement function, performance comparison * Create date: (2002-18 13:25:21) * @Return java.lang.string * @Param s java.lang.string * / public string replace (String SRCSTR, STRING OLDSTR, STRING Newstr) {Int i = srcstr.indexof (OldStr); StringBuffer SB = New StringBuffer (); if (i == -1) Return srcstr; sb.append (srcstr.substring (0, i) Newstr); if (i oldstr.length ()
If (! from.endswith ("/")) from = from "/"; if (! to.endswith ("/")) to = to "/"; file tt = new file (to); if (! tt.exists ()) tt.mkdirs (); string ss = ""; file ff = new file (from); if (ff.isdirectory ()) {file f [] = ff.listfiles (); for (INT i = 0; i