Java×Ö·û´®Ê¹ÓÃ×ܽá
Java×Ö·û´®Ê¹ÓÃ×ܽá
Ç°ÑÔ£º
ÕâƪÎÄÕµÄÄ¿µÄÊÇÌáÐÑ´ó¼Ò¶Ô×Ö·û´®ÈýÖÖÀàÐÍ×ö¸ö×ۺϵıȽϣ¬Ê¹µÃÔÚʹÓÃ×Ö·û´®ÈýÖÖÀàµÄʱºòÓиöÑ¡ÔñÒÀ¾Ý£¬ÕâÑù¿ÉÒÔ¼«´óÌá¸ß³ÌÐòÔËÐеÄЧÂÊ¡£Èç¹ûÄã¶ÔÕâÈý¸öÀàÒѾºÜÊìϤÁË£¬ÎÒÃ÷È·¸æËßÄ㣬ÄãÐèÒª¿´ÁË£¬Èç¹ûÄ㻹²»Ã÷°××Ö·û´®ÊÇʲô£¬ÏëÓиö´ó¸ÅÈÏʶ£¬ok£¬¼ÌÐø£¡
Èç¹ûÄãÏòѧϰÕâÈýÖÖÀà¾ßÌåÔõôÓõģ¬±§Ç¸£¬Çë¿´APIÎĵµÈ¥¡£
´ËÎÄÕ²ο¼ÁËAPIÎĵµ£¬µ«²»ÊÇAPIÎĵµµÄ¿½±´£¬Ã÷¼ø£¡
Ò»¡¢StringÀà
String À಻ÊÇÔʼ»ù±¾Êý¾ÝÀàÐÍ£¬ÔÚJavaÖУ¬×Ö·û´®ÊÇÒ»¸ö¶ÔÏó¡£
String Àà´ú±í×Ö·û´®¡£Java ³ÌÐòÖеÄËùÓÐ×Ö·û´®×ÖÃæÖµ£¨Èç "abc" £©¶¼×÷Ϊ´ËÀàµÄʵÀýÀ´ÊµÏÖ¡£
×Ö·û´®Êdz£Á¿£»ËüÃǵÄÖµÔÚ´´½¨Ö®ºó²»Äܸı䡣×Ö·û´®»º³åÇøÖ§³Ö¿É±äµÄ×Ö·û´®¡£ÒòΪ String ¶ÔÏóÊDz»¿É±äµÄ£¬ËùÒÔ¿ÉÒÔ¹²ÏíËüÃÇ¡£ÀýÈ磺
String str = "abc";
µÈЧÓÚ£º
char data[] = {'a', 'b', 'c'};
String str = new String(data);
ÏÂÃæ¸ø³öÁËһЩÈçºÎʹÓÃ×Ö·û´®µÄ¸ü¶àÀý×Ó£º
System.out.println("abc");
String cde = "cde";
Ïà¹ØÎĵµ£º
//JavaÎļþÏÂÔصļ¸ÖÖ·½Ê½
public HttpServletResponse download(String path, HttpServletResponse response) {
try {
// pathÊ ......
ÄãÔø¾ÐèÒªÓ¦ÓÃÖ´ÐÐÒ»¸öÈÎÎñÂð£¿Õâ¸öÈÎÎñÿÌì»òÿÖÜÐÇÆÚ¶þÍíÉÏ11£º30£¬»òÐí½ö½öÿ¸öÔµÄ×îºóÒ»ÌìÖ´ÐС£Ò»¸ö×Ô¶¯Ö´ÐжøÎÞÐë¸ÉÔ¤µÄÈÎÎñÔÚÖ´Ðйý³ÌÖÐÈç ¹û·¢ÉúÒ»¸öÑÏÖØ´íÎó£¬Ó¦ÓÃÄܹ»Öªµ½ÆäÖ´ÐÐʧ°Ü²¢³¢ÊÔÖØÐÂÖ´ÐÐÂð£¿ÄãºÍÄãµÄÍŶÓÊÇÓÃjava±à³ÌÂð£¿Èç¹ûÕâЩÎÊÌâÖÐÈκÎÒ»¸öÄã»Ø´ðÊÇ£¬ÄÇôÄãÓ¦¸ÃʹÓà Quartzµ÷¶ÈÆ÷¡£
¡¡¡¡
¡¡¡¡ ......
ÓÉÓÚJDKÊǹú¼Ê°æµÄ£¬ÔÚ±àÒëµÄʱºò£¬Èç¹ûÎÒÃÇûÓÐÓÃ-encoding²ÎÊýÖ¸¶¨ÎÒÃǵÄJAVAÔ´³ÌÐòµÄ±àÂë¸ñʽ£¬Ôòjavac.exeÊ×ÏÈ»ñµÃÎÒÃDzÙ×÷ϵͳĬÈϲÉÓõıàÂë¸ñʽ£¬Ò²¼´ÔÚ±àÒëjava³ÌÐòʱ£¬ÈôÎÒÃDz»Ö¸¶¨Ô´³ÌÐòÎļþµÄ±àÂë¸ñʽ£¬JDKÊ×ÏÈ»ñµÃ²Ù×÷ϵͳµÄfile.encoding²ÎÊý(Ëü±£´æµÄ¾ÍÊDzÙ×÷ϵͳĬÈϵıàÂë¸ñʽ£¬ÈçWIN2k£¬ËüµÄֵΪGBK)£¬È»º ......
String str = "ÖÐ";
String str1 = new String(str.getBytes("gbk"), "ISO8859-1");
String str2 = new String(str1.getBytes("ISO8859-1"), "gbk");
System.out.println(str2); //Êä³ö"ÖÐ" ......