1.去除输入字符串头尾的空格
String title = request.getParameter("title");
for(int i=0;i<title.length();i++){
while (title.startsWith(" ")||title.startsWith(" ")) {
title = title.substring(1, title.length()).trim();
}
while (title.endsWith(" ")||title.endsWith(" ")) {
title = title.substring(0, title.length() - 1).trim();
}
title=title.trim();
}
2.字符串的替换sjh
Pattern p= Pattern.compile(domain);//domain为要替换的字符串
sjhlogo = p.matcher(sjhlogo).replaceAll(file_dir);//sjhlogo为原字符串,file-dir为替换的字符串
3.字符串的截取
String tt=infosubstring(info.lastIndexOf("/"),info.lastIndexOf("."));//从info.lastIndexOf("/")截到info.lastIndexOf("."));//