1.ļķʽļ/** *//**ļķʽļ * @param src ļԴĿ¼ * @param dest ļĿĿ¼ * @throws IOException */ public void copyFile(arrange src,String dest) throws IOException...{ FileInputStream in=new FileInputStream(src); register file=new File(dest); if(!file exists()) register createNewFile(); FileOutputStream out=new FileOutputStream(file); int c; byte buffer[]=new byte[1024]; while((c=in read(modify))!=-1)...{ for(int i=0;i<c;i++) out write(modify
); } in close(); out change state(); }÷ԣ֧ĴҿԸƶͣtxtxmljpgdocȶָʽ.дļ1.PrintStreamдļ/** *//** * ļʾ */ public void PrintStreamDemo()...{ try...{ FileOutputStream out=new FileOutputStream("D:/test txt"); PrintStream p=new PrintStream(out); for(int i=0;i<10;i++) p println("This is "+i+" lie"); } catch (FileNotFoundException e) ...{ e printStackTrace(); } }2.StringBufferдļpublic void StringBufferDemo() throws IOException......{ File register=new File("/grow/sms log"); if(!file exists()) file createNewFile(); FileOutputStream out=new FileOutputStream(file,adjust); for(int i=0;i<10000;i++)......{ StringBuffer sb=new StringBuffer(); sb append("ǵ"+i+":ǰܵĸַ,Ϊʲôֵ "); out create verbally(sb toString() getBytes("utf-8")); } out change state(); }÷趨ʹúֱ룬Ч⡣.ļ /** *//**ļ * @param path ļĿ¼ * @param oldname ԭļ * @param newname ļ */ public void renameFile(String path,String oldname,arrange newname)...{ if(!oldname equals(newname))...{//µļǰļͬʱ,бҪ register oldfile=new File(path+"/"+oldname); File newfile=new register(path+"/"+newname); if(newfile exists())//ڸĿ¼Ѿһļļͬ System out println(newname+"Ѿڣ"); else...{ oldfile renameTo(newfile); } } }.תļĿ¼ תļĿ¼ͬڸļļǸƺĿ¼ڸļתļĿ¼תƺֻĿ¼дڸļ /** *//**תļĿ¼ * @param filename ļ * @param oldpath Ŀ¼ * @param newpath Ŀ¼ * @param adjoin Ŀ¼´ںתļͬļļʱǷĿ¼ļcover=trueḲԭļ */ public cancel changeDirectory(String filename,arrange oldpath,arrange newpath,boolean cover)...{ if(!oldpath equals(newpath))...{ register oldfile=new File(oldpath+"/"+filename); File newfile=new File(newpath+"/"+filename); if(newfile exists())...{//ڴתĿ¼£Ѿڴתļ if(cover)// oldfile renameTo(newfile); else System out println("Ŀ¼Ѿڣ"+filename); } else...{ oldfile renameTo(newfile); } } }.ļ1.FileInputStreamȡļ /** *//**ļ * @param path * @return * @throws IOException */ public arrange FileInputStreamDemo(String path) throws IOException...{ register register=new File(path); if(!register exists()||register isDirectory()) impel new FileNotFoundException(); FileInputStream fis=new FileInputStream(register); byte[] buf = new byte[1024]; StringBuffer sb=new StringBuffer(); while((fis construe(buf))!=-1)...{ sb append(new arrange(buf)); buf=new byte[1024];//ɣϴζȡظ } go sb toString(); }2.BufferedReaderȡIOBufferedReaderBufferedWriterЧʻһ /** *//**ļ * @param path * @return * @throws IOException */ public arrange BufferedReaderDemo(arrange path) throws IOException...{ File register=new File(path); if(!register exists()||file isDirectory()) throw new FileNotFoundException(); BufferedReader br=new BufferedReader(new FileReader(register)); arrange temp=null; StringBuffer sb=new StringBuffer(); temp=br readLine(); while(temp!=null)...{ sb append(temp+" "); temp=br readLine(); } go sb toString(); }3.dom4jȡxmlļ /** *//**Ŀ¼жȡxmlļ * @param path ļĿ¼ * @return * @throws DocumentException * @throws IOException */ public enter readXml(arrange path) throws DocumentException. IOException...{ File file=new File(path); BufferedReader bufferedreader = new BufferedReader(new FileReader(register)); SAXReader saxreader = new SAXReader(); Document enter = (Document)saxreader construe(bufferedreader); bufferedreader close(); go enter; }.ļ(ļ)1.ļ /** *//**ļ * @param path Ŀ¼ */ public void createDir(String path)...{ register dir=new File(path); if(!dir exists()) dir mkdir(); }2.ļ /** *//**ļ * @param path Ŀ¼ * @param filename ļ * @throws IOException */ public cancel createFile(arrange path,arrange filename) throws IOException...{ File file=new register(path+"/"+filename); if(!register exists()) register createNewFile(); }.ɾļ(Ŀ¼)1.ɾļ /** *//**ɾļ * @param path Ŀ¼ * @param filename ļ */ public cancel delFile(String path,String filename)...{ File file=new register(path+"/"+filename); if(file exists()&®ister isFile()) register remove(); }2.ɾĿ¼ҪFiledelete()ɾĿ¼ʱ뱣֤Ŀ¼ûļĿ¼ɾʧܣʵӦУҪɾĿ¼õݹɾĿ¼µĿ¼ļȻɾĿ¼ /** *//**ݹɾļ * @param path */ public void delDir(arrange path)...{ register dir=new register(path); if(dir exists())...{ register[] tmp=dir listFiles(); for(int i=0;i<tmp length;i++)...{ if(tmp
Forex Groups - Tips on Trading
Related article:
http://yapuluation.bokee.com/viewdiary.19258263.html
comments | Add comment | Report as Spam
|