/**
* Read TXT files
*/
Public void readertxt (){
List <string> emaillist = new arraylist <string> ();
List <string> emaillocationlist = new arraylist <string> ();
File file = new file ("C: // Documents and Settings // administrator // desktop // email2.txt ");
Try
{
Bufferedreader input = new bufferedreader (New filereader (File ));
String text;
While (text = input. Readline ())! = NULL)
// System. Out. println (text );
Emaillist. Add (text );
} Catch (exception ex ){}
If (emaillist! = NULL ){
For (INT I = 0; I <emaillist. Size (); I ++ ){
String emailstr = emaillist. Get (I );
If (emailstr! = NULL &&! "". Equals (emailstr )){
String [] emailarray = emailstr. Split (";");
For (Int J = 0; j <emailarray. length; j ++ ){
If (emailarray [J]! = NULL &&! "". Endswith (emailarray [J]) {
Emaillocationlist. Add (emailarray [J]);
}
}
}
}
}
For (INT I = 0; I <emaillocationlist. Size (); I ++ ){
System. Out. println (emaillocationlist. Get (I ));
}
}
/**
* Writing files
*/
Public void writerfile (){
File file = new file ("C: // Documents and Settings // administrator // desktop // successfully sent. txt ");
Try {
Filewriter fw = new filewriter (File );
FW. Write ("wangwei <wangwei.0822>/R/N ");
FW. Write ("wangwei <wangwei.0822>/R/N ");
FW. Flush ();
FW. Close ();
} Catch (ioexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
}
/**
* File copy
*/
Public void copyfile (){
File filei = new file ("D: // aaa.txt ");
File fileo = new file ("D: // bbb.txt ");
Try {
Fileinputstream in = new fileinputstream (filei );
Fileoutputstream out = new fileoutputstream (fileo );
Byte [] B = new byte [1024];
While (in. Read (B)>-1 )){
Out. Write (B );
}
In. Close ();
Out. Close ();
} Catch (filenotfoundexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
} Catch (ioexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
}