适用于xml、json以及分条字符串
/**
* 字符串格式化处理(实现字符串在回车换行和空格功能)
* @param xml
*/
private String convertstr(String xmlorjson) {
if (xmlorjson == null || "".equals(xmlorjson) || "null".equals(xmlorjson)) {
return "";
}
//处理字符串
String[] beforechar = {"", "¢", "£", "¥", "€", "§", "©", "®", "™", "×", "÷"};
String[] afterchar = {"<", ">", "¢", "£", "¥",
"€", "§", "©", "®", "™", "×", "÷"};
for (int i = 0; i < beforechar.length; i++) {
xmlorjson = xmlorjson.replaceAll(beforechar[i], afterchar[i]);
}
xmlorjson = xmlorjson.replaceAll("\n", "");
xmlorjson = xmlorjson.replaceAll(" ", " ");
xmlorjson = xmlorjson.replaceAll("\t", " ");
return xmlorjson;
}