Java中HTML与Textarea换行符的相互转换

HTML与Textarea中换行符相互转化。

/**
 * Html转换为TextArea文本
 *
 * @return
 */
public static String HtmlToText(String str) {
	if (str == null) {
		return "";
	} else if (str.length() == 0) {
		return "";
	}
	str = str.replaceAll("<br />", "\r\n");
	return str;
}

/**
 * TextArea文本转换为Html:写入数据库时使用
 */
public static String Text2Html(String str) {
	if (str == null) {
		return "";
	} else if (str.length() == 0) {
		return "";
	}
	str = str.replaceAll("\r\n", "<br />");
	return str;
}