Java Simple Digital Processing

Source: Internet
Author: User
Tags stringbuffer

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.