[Java]
Package test;
Import java. io. BufferedReader;
Import java. io. File;
Import java. io. FileInputStream;
Import java. io. InputStreamReader;
/**
* @ Author JavaAlpha 02:06:27 UTF8 txt file garbled Processing
*/
Public class QQGroup {
/**
* @ Param args
*/
Public static void main (String [] args ){
ReadTxt ();
}
Private static void readTxt (){
Try {
File f1 = new File ("e:/qqgroup.txt"); // open the File
FileInputStream in = new FileInputStream (f1 );
// Specify the UTF-8 format to read when reading the file
BufferedReader br = new BufferedReader (new InputStreamReader (in,
"UTF-8"); // read the file
String name = "";
String numb = "";
String str;
System. out. println ("group name ************** group number ");
While (str = br. readLine ())! = Null ){
If (str. indexOf ("class = \" addrtitle \ ">")>-1 ){
Name = str. substring (str. indexOf (">"), str. indexOf ("</"));
System. out. println ("group name:" + name );
}
If (str. indexOf ("gid =")>-1 ){
Numb = str. substring (str. indexOf ("gid ="), str. indexOf ("@ groupmail "));
System. out. println ("group number:" + numb );
}
}
In. close (); // close reading www.2cto.com
} Catch (Exception e1) {// if an error occurs, process it here
E1.printStackTrace (); // print the error message
}
}
}
Author: JavaAlpha