1 ImportJava.io.*;2 3 classPrintthreadextendsThread4 {5 Private intThread_count;6 PublicPrintthread (intc)7 {8Thread_count =C;9 }Ten One Public voidRun () A { -String Outpath = "Chinese" + string.valueof (thread_count) + ". txt"; - Try the { - - -FileReader FR =NewFileReader ("Chinese.txt"); + Char[] buffer =New Char[5]; - + intHasread = 0; A atFileWriter FW =NewFileWriter (outpath); - - while(Hasread = fr.read (buffer)) >0) - { - //System.out.print (new String (buffer, 0, hasread)); -Fw.write (buffer, 0, hasread); in } - fr.close (); to fw.close (); + } - Catch(IOException e) the { * } $ Panax Notoginseng } - } the + A classfileinputstreamtest the { + Public Static voidMain (string[] args) - { $ $Printthread pt1 =NewPrintthread (1); - Pt1.start (); - thePrintthread pt2 =NewPrintthread (2); - Pt2.start ();Wuyi the } -}
Java Filereader/filewriter