Java reads txt text and intercepts strings

Source: Internet
Author: User

Package com. test;

Import java. io. BufferedReader;
Import java. io. BufferedWriter;
Import java. io. File;
Import java. io. FileNotFoundException;
Import java. io. FileReader;
Import java. io. FileWriter;
Import java. io. IOException;

Public class TextConvertor {

Public static String convertingStr (String lineStr ){
String retVal = "";
Return retVal;
}

Public static String readPath = "C: \ legal ents and Settings \ Administrator \ Desktop http://www.cnblogs.com/coconut_zhang/admin/file://1.txt ";
Public static String writePath = "C: \ legal ents and Settings \ Administrator \ Desktop http://www.cnblogs.com/coconut_zhang/admin/file://1-bak.txt ";

/**
* @ Param args
* @ Throws IOException
*/
Public static void main (String [] args) throws IOException {
File file = new File (readPath );
If (! File. exists ()){
System. out. println ("File not exist! ");
System. exit (0 );
}
BufferedReader br = new BufferedReader (new FileReader (readPath ));
BufferedWriter bw = new BufferedWriter (new FileWriter (writePath ));
String temp = "";
While (temp = br. readLine ())! = Null ){
System. out. println (temp );
Int I = 0;
For (I = 0; I <temp. length (); I ++ ){
String subTemp = temp. substring (I, I + 1 );
If (subTemp. matches ("[^ \ x00-\ xff]") {
System. out. println (subTemp + ": true ");
Break;
} Else
System. out. println (subTemp + ": false ");
}
If (I = temp. length ())
Temp = temp. substring (0, I-1) + "\ t" + temp. substring (I );
Else
Temp + = "\ t ";
Bw. write (temp );
Bw. newLine ();
}
Bw. flush ();
Br. close ();
Bw. close ();
}
}

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.