ImportJava.io.BufferedOutputStream;ImportJava.io.BufferedReader;ImportJava.io.BufferedWriter;ImportJava.io.File;ImportJava.io.FileInputStream;ImportJava.io.FileOutputStream;ImportJava.io.FileReader;ImportJava.io.FileWriter;Importjava.io.IOException;ImportJava.io.InputStreamReader;ImportJava.io.OutputStream;ImportJava.io.OutputStreamWriter;/*** <p> * title:changenumber * </p> * <p> * description:10w numbers, 5 sets of cut for 3 a group, run time 3 seconds. * </p> * <p> * Location:frostburg * </p> * *@author: Eric.chen * @date: September 19, 2017 morning 10:57:26*/ Public classChangeNumber { Public Static voidMain (string[] args)throwsIOException {//FileReader reading a text fileChangeNumber re =NewChangeNumber (); FileReader FR=NewFileReader ("F:\\number.txt"); String Str= ""; for(inti = 0; I < 10000; i++) {//The number of cycles depends on the number of digits CharLen1 = (Char) Fr.read ();//str + =len1; } fr.close (); String T1=str; String Finalnumber= Re.cutnumber (t1);//call the Cut function and return the number after cutting//System.out.println (Finalnumber); //write the results to another text fileFileWriter FW =NewFileWriter ("F:\\new.txt"); Char[] Chararray = Finalnumber.tochararray ();//Convert a cut string to a character array for(inti = 0; i < chararray.length; i++) {fw.write (chararray[i]);//writes one to the specified text at a timeFw.flush ();//Refresh Stream} fw.close ();//Close the stream } PublicString Cutnumber (String str)//cut strings, cut 3 at a time{String str1= Str.replaceall ("", "");//The calling method replaces all the spaces in the stringStringBuffer SB =NewStringBuffer (); for(inti = 0; I < Str1.length ()-3; i + = 3) {String Sub= Str1.substring (i, i + 3);//CuttingSb.append (sub);//ConnectionSb.append ("");//separated by spaces} String STR3= Sb.tostring ();//Convert to full string returnSTR3; }}
Java Simple Digital Processing