MyUtil语句程序把utf-8编码转换为tomcat自带可读的iso-8859-1编码简单快捷
package utils;
import java.io.UnsupportedEncodingException;
public class MyUtil {
public static String toUnicode(String s)
{
if(s == null || s.equals("")) {
return s="";
}
try {
s = new String(s.getBytes("iso-8859-1"),"utf-8");
//把utf-8编码转换为tomcat
} catch(UnsupportedEncodingException e)
{
s = ""; e.printStackTrace();
}
return s;
}
public static int toInt(String s)//字符串转整体
{
if(s == null || s.equals("")) {
s = "0";
}
int i = 0;
try {
i = Integer.parseInt(s);
}catch(Exception e)
{
i = 0;
e.printStackTrace();