网址过滤
String website = info.getWebsite();
if (StringUtil.isNotEmpty(website)) {// 过滤http
if (website.indexOf("://") != -1) {
website = website.substring(website.indexOf("://") + 3);
}
if (website.indexOf("/") != -1) {
website = website.substring(0, website.indexOf("/"));
}
website = website.split("\\?")[0]; // 过滤多余的参数部分
}
p.setWebsiteStr(website);
字符替换
String removeStr = "(有限合伙)";
structure.setShareholder(shareholder.replace(removeStr, ""));
字符截取
1、去除最后一位:structure.setShareholdingratio(shareholdingratio.substring(0, shareholdingratio.length() - 1));
2、 // http://www.wangdaibus.com/thread-188273-1-1.html 获取tid 188273
link = link.split("-")[1];
link = link.split("-")[0];
Long afterLink = Long.parseLong(link);
3、区分文件名,文件格式
String input = "7421847.12940219.124214.exe"; String houzhui = input.substring(input.lastIndexOf(".") + 1); System.out.println("后缀名为:" + houzhui); // exe int i = input.lastIndexOf(houzhui); String wenianming = input.substring(0, i - 1); System.out.println("文件名为:" + wenianming); // 7421847.12940219.124214