將JAVA 數(shù)組轉(zhuǎn)換成以某個字符分隔的字符串
package tool;
import java.io.UnsupportedEncodingException;
public class Common {
public static String toUtf8(String value) throws UnsupportedEncodingException {
String v = new String(value.getBytes("ISO-8859-1"),"UTF-8");
return v;
}
public static String arrToStr(String[] str,String type) {
String strs = "";
for(String s : str) {
strs += s + type;
}
strs = strs.substring(0,strs.length()-1);
return strs;
}
}
調(diào)用:
String[] hobby = request.getParameterValues("hobby");
String hobbys = Common.arrToStr(hobby, "/");
out.println(Common.toUtf8(hobbys));
顯示結(jié)果如下:

