軟件開發(fā)重要黑馬復(fù)習(xí)代碼總結(jié)_第1頁
軟件開發(fā)重要黑馬復(fù)習(xí)代碼總結(jié)_第2頁
軟件開發(fā)重要黑馬復(fù)習(xí)代碼總結(jié)_第3頁
軟件開發(fā)重要黑馬復(fù)習(xí)代碼總結(jié)_第4頁
軟件開發(fā)重要黑馬復(fù)習(xí)代碼總結(jié)_第5頁
已閱讀5頁,還剩21頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

importimportpublicclassSystemDemopublicstaticvoidmain(String[]{Propertiespro=for(Objectobj:pro.keySet())Stringvalue=(String)pro.get(obj); }System.setProperty("mykey1"iamfwj");StringvSystem.getProperty("haha");}} 獲取系統(tǒng)屬性信息:PropertiesimportimportpublicclassRuntimeDemopublicstaticvoidmain(String[]args)throwsExceptionRuntimer=Runtime.getRuntime();}}Runtime該方式是staticRuntimegetRuntime();importimportimportimportpublicclassDateDemopublicstaticvoidmain(String[]{Dated=newDate();SimpleDateFormatsdf=newSimpleDateFormat("yyyyMMddStringtime=sdf.format(d);longnowtime=System.currentTimeMillis();Datenowdate=newDate(nowtime);}}importimportpublicclassCalendarDemopublicstaticvoidmain(String[]args)Calendarintintintint}}年privateprivatestaticvoidGet_February_days()//TODOAuto-generatedmethodstubCalendarc=Calendar.getInstance();c.set(2008,2,1);c.add(Calendar.DAY_OF_MONTH,-1);}詳細(xì)總結(jié)importimportjava.io.FileWriter;importjava.io.IOException;publicclassFileWriterDemo{publicstaticvoidmain(String[]args)throwsException//TODOAuto-generatedmethodFileWriterfw=newfw.write("lala}}構(gòu)造函數(shù)中第二參數(shù)帶false,寫入時(shí)覆蓋現(xiàn)有內(nèi)容,進(jìn)行續(xù)寫默認(rèn)為falsefw.write("lalafw.write("lalaimportimportclass{publicstaticvoidmain(String[]{FileWriterfw=null;{fw=newFileWriter("demo.txt");}catch(IOException{}{{}catchcatch(IOException{}}}}importimportimportpublicclassFileReaderDemopublicstaticvoidmain(String[]args)throwsExceptionFileReaderfr=newFileReader("filewriter.txt");int1){}}}importimportpublicclassFileReaderDemo2publicstaticvoidmain(String[]args)throws{FileReaderfr=newchar[]buf=newchar[1024];intch=0;}}}{FileReaderfr=newFileReader("filewriter.txt");FileWriterfw=newFileWriter("file_copy.txt");intch=0;1){}}privateprivatestaticvoidcopy_2()throwsIOException//TODOAuto-generatedmethodFileReaderfr=newFileReader("filewriter.txt");FileWriterfw=newFileWriter("file_copy2.txt");char[]buf=newchar[1024];int1){}}privateprivatestaticvoidcopy_3()//TODOAuto-generatedmethodstubFileReaderfr=null;FileWritertryfw=newFileWriter("file_3.txt");int1){}}catch(IOExceptione)//TODOAuto-generatedcatchthrownewRuntimeException("讀寫失敗}ry{}catch(IOExceptione)//TODOAuto-generatedcatchthrownewRuntimeException("關(guān)閉文件讀入流失敗敗}}ry{}catch(IOExceptione)//TODOAuto-generatedcatch}}}}importimportpublicclassBufferedWriterDemopublicstaticvoidmain(String[]args)throwsException//TODOAuto-generatedmethodFileWriterfw=newBufferedWriterbfw=newBufferedWriter(fw);for(inti=0;i<5;i++)}}}BuffedredBuffedrednewlineimportpublicclassCopyTextByBufpublicstaticvoidmain(String[]{FileReaderfr=null;FileWriterfw=null;BufferedReaderbfr=null;BufferedWriterbfw=null;try{fr=newfw=newFileWriter("copytextbybuf.txt");bfr=newBufferedReader(fr);bfw=newBufferedWriter(fw);Stringline=null;while((line=bfr.readLine())}}catch(Exceptione)//TODOAuto-generatedcatchthrownewRuntimeException("文件讀寫異常}finallyif(bfr!=null)try}catch(IOExceptione)//TODOAuto-generatedcatch}}}if(bfw!=null)try}catch(IOExceptione)//TODOAuto-generatedcatch}}}}}importimportpublicclassLineNumberdomepublicstaticvoidmain(String[]args)throws{FileReaderfr=newFileReader("file.txt");LineNumberReaderlfr=newLineNumberReader(fr);Stringline=null;while((line=lfr.readLine())!={System.out.println(lfr.getLineNumber()+":"+}}}importimportclassMyBufferedReaderextends{privateReaderr;{this.r=}publicStringmyReadLine()throws{StringBuildersb=newintch={return}return}publicintread(char[]cbuf,intoff,intlen)throws{returnr.read(cbuf,off,len)}publicvoidclose()throws{}publicvoidmyClose()throws{}}publicclass{publicstaticvoidmain(String[]args)throws{FileReaderfr=newFileReader("file.txt");MyBufferedReadermyBuf=newMyBufferedReader(fr);Stringline=null;{{}}}privateprivatestaticvoidWriteFile_1()throwsException//TODOAuto-generatedmethodFileOutputStreamfop=newFileOutputStream("fileout.txt");fop.write("woshiyigexiaolongren".getBytes());fop.write("我是漢字".getBytes());}privateprivatestaticvoidReadFile_1()throwsException//TODOAuto-generatedmethodFileInputStreamfis=newintch={}}FileInputStreamprivateprivatestaticvoidReadFile_2()throwsException//TODOAuto-generatedmethodFileInputStreamfis=newintbytebuf=newbyte[fis.available()];System.out.println(newString(buf));}}importimportpublicclassCopyPicpublicstaticvoidmain(String[]args)throwsException//TODOAuto-generatedmethodFileInputStreamfis=newFileInputStream("pic.png");FileOutputStreamfos=newFileOutputStream("pic_copy.png");intlen=0;byte[]buf=newbyte[1024];}}}importimportpublicclassCopyMp3publicstaticvoidmain(String[]args)throwsException BufferedOutputStreambfos=newnewintby=while((by=bfis.read())!=-{}}}注意盤符為publicclassReadinpublicstaticvoidmain(String[]args)throws{InputStreamin=System.in;StringBuildersb=newStringBuilder();while(true)intch=if(ch==if(ch=='\n')Strings=ifsb.delete(0,sb.length());}}}}publicpublicclassTransStreamDemopublicstaticvoidmain(String[]args)throwsExceptionInputStreamin=InputStreamReaderisr=newInputStreamReader(in);BufferedReaderbufr=newBufferedReader(isr);OutputStreamout=OutputStreamWriterOutputStreamWriterosw=newOutputStreamWriter(out);BufferedWriterbufw=newBufferedWriter(osw);Stringline=while((line=bufr.readLine())!=null)if}}}importimportpublicclassTransStreamDemo2publicstaticvoidmain(String[]args)throwsBufferedReaderbufrnewBufferedReader(newBufferedWriterbufw=newStringline=while((line=bufr.readLine())!=null)if}}}importimportjava.io.IOException;importjava.io.PrintStream;importjava.util.Date;publicclassExceptionInfopublicstaticvoidmain(String[]args)throws{{{int[]arr=newint[2];}catch(Exception{{Dated=newSimpleDateFormatsdf=newSimpleDateFormat("yyyy-MM-Strings=PrintStreamps=newPrintStream("exeception.log");}catch(IOException{thrownewRuntimeException("日志文件創(chuàng)建失敗}}}}importimportimportimportpublicclassSystemInfopublicstaticvoidmain(String[]args)throws{Propertiespro=// pro.list(new}}建,返回false。booleanmkdir():創(chuàng)建文件夾。falsel。longlength()privateprivatestaticvoid{Filedir=newFile("D:\\");File[]files=dir.listFiles();for(Filef:files){}}privateprivatestaticvoidlistfileroots()//TODOAuto-generatedmethodstubFile[]roots=File.listRoots();for(Filef:roots){}}importimportpublicclasslistallfilespublicstaticvoidmain(String[]{Filedir=newshowDir(dir,}privatestaticvoidshowDir(Filedir,intlevel)//TODOAuto-generatedmethodstubFile[]for(File}}}}privatestaticStringgetlevel(intlevel)//TODOAuto-generatedmethodstubStringBuildersb=newStringBuilder();for(inti=0;i<level;{sb.insert(0,"|--}return}}注意:隱藏文件的問題importpublicclassremovedirdemopublicstaticvoidmain(String[]{Filedir=new}privatestaticvoidremovedir(Filedir)//TODOAuto-generatedmethodstubFile[]files=dir.listFiles();for(Filef:files)if(f.isDirectory())}elseif(f.isFile())}}}}}importimportjava.io.File;importjava.io.FileWriter;importjava.util.List;publicclassJavaFileListpublicstaticvoidmain(String[]args)throws{Filedir=newList<File>filelist=newArrayList<File>();}privatestaticvoidFilelist_to_txt(List<File>filelist)Exception//TODOAuto-generatedmethodBufferedWriterbufw=newBufferedWriter(newfor(int}}privatestaticvoidWriteFiletoList(Filedir,List<File>{//TODOAuto-generatedmethodstubFile[]files=dir.listFiles();for(Filef:files)}if(f.isFile()&&f.getName().endsWith(".txt")){filelist.a}}}////將info.txtprivatestaticvoidmethod_2()throwsIOException//TODOAuto-generatedmethod Propertiespro=newProperties();Stringline=null;String[]arr=line.split("=");}}importimportimportpublicpublicclassRunCountpublicstaticvoidmain(String[]args)throws{Filef=new}Propertiespro=newProperties();FileInputStreamfis=newFileInputStream(f);intStringnt(value);if(count>5){}}pro.setProperty("time",count+"");FileOutputStreamfos=newFileOutputStream(f);//load(InputStreamProperties表}}importimportjava.io.FileInputStream;importjava.io.FileOutputStream;importjava.util.Enumeration;importjava.util.Vector;publicclassSequenceDemopublicstaticvoidmain(String[]args)throws{Vector<FileInputStream>v=v.add(newFileInputStream("file2.txt"));v.add(newFileInputStream("file2.txt"));v.add(newFileInputStream("file2.txt"));Enumeration<FileInputStream>en=v.elements();直到到達(dá)包含的最后一個(gè)輸入流的文件末尾為止FileOutputStreamfos=newFileOutputStreambyte[]buf=newbyte[1024];intlen=0;}}}privateprivat

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論