Ljava.lang.String 表示一个字符串数组,即String[] tmp;
String.replace 与String.replaceAll
replace是基于char 或字符串里德替换;
replaceAll是基于正则表达式进行替换。
java.util.Scanner 可以扫瞄文件,字符串以及键盘输入的字符,有与split相同的功能,默认用token:空格。
判断java对象是不是 数组 :
public boolean isClass(Object obj){
Class c=obj.getClass();
return c.isArray();
}
java.util.ConcurrentModificationException参考资料
http://www.blogjava.net/sitinspring/archive/2007/12/03/165006.html
取得vm内存使用情况:
Runtime.getRuntime().totalMemory()
Runtime.getRuntime().freeMemory()
正则表达式:
String tmp2 = "<a href=\"$seourl.encodeURL%28\" storeitem.html?vid=\"20081218001&iid=14123\" )=\"\">";
String tmp = "$seourl.encodeURL[\"storeitem.html?vid=$vendorSettingsDTO.vendorId&iid=14123\")\">";
String tmp3 = "seourl.encodeURL[^(]{3}";
String tmp4 ="vid=\"[0-9]{11}&[^amp;]{4}";
Pattern p = Pattern.compile(tmp3);
Matcher match = p.matcher(tmp2);
System.out.println(match.replaceAll("seourl.encodeURL("));
Matcher match2 = p.matcher(tmp2);
System.out.println(match2.find());
jsp下载文件设置:
response.setCharacterEncoding("gb2312");
response.reset();//可以加也可以不加
response.setContentType("binary/octet-stream");
String filedisplay = "0000000191.xls";
filedisplay = URLEncoder.encode(filedisplay,"UTF-8");
response.addHeader("Content-Disposition","attachment;filename=" + filedisplay);
OutputStream os=response.getOutputStream();//把相应的流,放进去就ok
例:
InputStream ins;
try {
ins = new FileInputStream("");
byte buff[] = new byte[1024];
int iRead = 1;
while (iRead > 0) {
iRead = ins.read(buff);
if (iRead > 0) {
outs.write(buff, 0, iRead);
}
}
outs.flush();
outs.close();
ins.close();
} catch (IOException ex3) {
ex3.printStackTrace();
return false;
}
matches与find
例:\\s{2,}包含连续空格,就提示出错信息
matches是匹配,匹配是根据一定的格式去比较,上面的正则表达式就是错误的,
应该是\\S*\\s{2,}\\S*,这个正则就匹配aa ddd
find是找到,上面正则是正确的,只需要找到2个连续的空格就行了