Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java byteÓëchar»¥×ªÔ­Àí ת

Ò»¡¢×Ö½ÚºÍunicode
JavaÄÚºËÊÇunicodeµÄ£¬¾ÍÁ¬classÎļþÒ²ÊÇ£¬µ«ÊǺܶàýÌ壬°üÀ¨Îļþ/Á÷µÄ±£´æ·½Ê½ÊÇʹÓÃ×Ö½ÚÁ÷µÄ¡£Òò´ËJavaÒª¶ÔÕâЩ×Ö½ÚÁ÷¾­ÐÐת»¯¡£ charÊÇunicodeµÄ£¬¶øbyteÊÇ×Ö½Ú¡£JavaÖÐ byte/char»¥×ªµÄº¯ÊýÔÚsun.ioµÄ°üÖмäÓС£ÆäÖÐByteToCharConverterÀàÊÇÖе÷¶È£¬¿ÉÒÔÓÃÀ´¸æËßÄ㣬ÄãÓÃµÄ convertor¡£ÆäÖÐÁ½¸öºÜ³£Óõľ²Ì¬º¯ÊýÊÇ£º
public static ByteToCharConverter getDefault();
public static ByteToCharConverter getConverter(String encoding);
Èç¹ûÄã²»Ö¸¶¨converter£¬Ôòϵͳ»á×Ô¶¯Ê¹Óõ±Ç°µÄencoding,gbƽ̨ÉÏÓÃgbk,enƽ̨ÉÏÓÃ8859_1¡£
byte ——¡µchar£º
"Äã"µÄgbÂëÊÇ£º0xc4e3 ,unicodeÊÇ0x4f60
String encoding = "gb2312";
byte b[] = {(byte)'\u00c4',(byte)'\u00e3'};
ByteToCharConverter converter = ByteToCharConverter.getConverter(encoding);
char c[] = converter.convertAll(b);
for (int i = 0; i < c.length; i++) {
System.out.println(Integer.toHexString(c[i]));
}
½á¹ûÊÇʲô£¿0x4f60
Èç¹ûencoding ="8859_1"£¬½á¹ûÓÖÊÇʲô£¿0x00c4,0x00e3
Èç¹û´úÂë¸ÄΪ£º
byte b[] = {(byte)'\u00c4',(byte)'\u00e3'};
ByteToCharConverter converter = ByteToCharConverter. getDefault();
char c[] = converter.convertAll(b);
for (int i = 0; i < c.length; i++) {
    System.out.println(Integer.toHexString(c[i]));
}
½á¹û½«ÓÖÊÇʲô£¿
Õâ¾ÍÒª¸ù¾Ýƽ̨µÄ±àÂë¶ø¶¨¡£
char ——¡µbyte£º
    String encoding = "gb2312";
    char c[] = {'\u4f60'};
    CharToByteConverter converter = CharToByteConverter.getConverter(encoding);
    byte b[] = converter.convertAll(c);
    for (int i = 0; i < b.length; i++) {
       System.out.println(Integer.toHexString(b[i]));
    }
½á¹ûÊÇʲô£¿0x00c4,0x00e3
Èç¹ûencoding ="8859_1"£¬½á¹ûÓÖÊÇʲô£¿0x3f
Èç¹û´úÂë¸ÄΪ
String encoding = "gb2312";
    char c[] = {'\u4f60'};
    CharToByteConverter converter = CharToByteConverter.getDefault();
  &


Ïà¹ØÎĵµ£º

Java¶àÏß³ÌÖ®ThreadLocal_1

ThreadLocalµÄºËÐÄ˼ÏëºÜ¼òµ¥£ºÎªÃ¿¸ö¶ÀÁ¢µÄÏß³ÌÌṩһ¸ö±äÁ¿µÄ¸±±¾¡£
    ThreadLocalÔòʹÓÃÁË“¿½±´¸±±¾”µÄ·½Ê½£¬ÈËÈËÓзݣ¬ÄãÓÃÄãµÄ£¬ÎÒÓÃÎҵģ¬´ó¼Ò»¥²»Ó°Ï죬ÊÇ“ÒԿռ任ʱ¼ä”¡£Ã¿¸öÏß³ÌÐ޸ıäÁ¿Ê±£¬Êµ¼ÊÉÏÐ޸ĵÄÊDZäÁ¿µÄ¸±±¾£¬²»ÅÂÓ°Ïìµ½ÆäËüÏ̡߳£
 
  & ......

JavaÃοªÊ¼µÄµØ·½

JavaÃοªÊ¼µÄµØ·½
Ï£ÍûÊǼáÈ͵ĹÕÕÈ£¬ÈÌÄÍÊÇÂÃÐдü£¬Ð¯´øËüÃÇ£¬ÈË¿ÉÒÔµÇÉÏÓÀºãÖ®ÂÃ;¡£--Bertrand Russell
Java:¸ßЧ¿ì½Ý¿çƽ̨¿ÉÒÆÖ²
³ÌÐòÔ±£ºJavaÓïÑÔ±¾Éí£¨»ù±¾Óï·¨ºÍ¸ÅÄԭÀíÓ¦Óã©£»JavaÓ¦Óÿª·¢
Êé¼®£ºJava±à³Ì˼Ï룻Java½Ì³Ì£»ÉîÈ뿪·¢Java Web¿ª·¢ÄÚÄ»µÈ
ÃοªÊ¼µÄµØ·½
01Ò»ÃÅÓïÑÔ¾«Í¨µÄ±ØÒªÌõ¼þ
02²Ù×÷ÏµÍ ......

JAVA(Èý)


JavaÔÓ̸£¨Áù£© 
        ÕâƪÊDZÊÕß´òËãдµÄJ2se²¿·ÖµÄ×îºóһƪÁË£¬Õâƪ½áÊøÖ®ºó£¬ÔÙдJ2ee²¿·Ö£¬²»ÖªµÀÊÇ·ñ»¹ºÏÊÊдÔÚÕâ¸ö°æ¿é£¿´ó¼Ò¿ÉÒÔ¸øµãÒâ¼û£¬Ð»Ð»´ó¼Ò¶ÔСµÜÕâô¹ÄÀøһ·дÍêÇ°ÁùƪJavaÔÓ̸µÄJ2se²¿·Ö¡£×îºóÕâƪ´òËã̸һ̸JavaÖеÄRMI»úÖƺÍJVMɳÏ䰲ȫ¿ò¼Ü¡£&nbs ......

JavaÖÐ×Ö·û´®ÓëASCIIÏ໥ת»»


import java.io.UnsupportedEncodingException;
public class T {
 public static void main(String[] args) throws UnsupportedEncodingException {
  t1();//ASCIIת»»Îª×Ö·û´®
  t2();//×Ö·û´®×ª»»ÎªASCIIÂë
 }
 public static void t1(){//ASCIIת»»Îª×Ö·û´®
   ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ