Java正则表达式
package com.sy.grasp;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegularExpression {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
/*String [] fakeFileData ={
"justin\t64/5/26\t09323432434\t4546465",
"momor\t68/7/23\t43543653\t34535435"
};
for(String data : fakeFileData){
String[] tokens=data.split("\t");
for(String token:tokens){
System.out.print(token+"\t|");
}
System.out.println();
}
* 显示结果:
* justin |64/5/26 |09323432434 |4546465 |
momor |68/7/23 |43543653 |34535435 |
* */
/*String text="abcdebcadxbc";
String[] tokens=text.split(".bc");
for(String token:tokens){
System.out.print(token+" ");
}
System.out.println();
tokens=text.split("..cd");
for(String token:tokens){
System.out.print(token+" ");
}
System.out.println();
* 返回结果是:
* d ad
ebcadxbc
解释:使用.bc来作比对,由于符合的子字符串有abc ebc xbc 3个,所以split()方法会使用这三个字符串来做字符串分离
,返回的就是不符合表达式.bc的d和ad了,同理..cd
* */
/*BufferedReader reader=new Bu
相关文档:
private static List cloneObject(
Object obj) throws Exception {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(obj);
ByteArrayInputStream byt ......
send mail use smtp .u can send text or html, send to many peoples if u have a email user and pwd and the smtp of the email which u use.
package org.lc.smtp;
import java.io.IOException;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.mail.Message;
import javax.mai ......
try {
Runtime.getRuntime().exec("C:\\xxx.exe");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} ......