[Definition]
// String 생성자로 byte형 array를 받게 되면, default charset을 사용하여 bytes의 array를 decoding해서 새로운 String을 생성하게 합니다.
// 위에랑 비슷하다. 대신 charsetName이란 String형 옵션을 주면 default charset이 아닌 charsetName 이름의 charset을 가지고 decoding을 시도합니다.
// getBytes(String charsetName): this String을 지정된 charset을 이용해서 byte[]로 encode함
// getByte(): this String을 default charset을 이용해서 byte[]로 encode함
[Example]
/*
Text : This is an example
Text [Byte Format] : [B@7ac4b626
Text [Byte Format] : [B@7ac4b626
Text [Ascii Format] : 84 104 105 115 32 105 115 32 97 110 32 101 120 97 109 112 108 101
Text Decryted : This is an example
[Example]
/*
str1 = 안녕 the world! 123
str2 = ??? the world! 123
str3 = 안녕 the world! 123
*/
[Reference]
http://blog.naver.com/cjyjava?Redirect=Log&logNo=20198661689
http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#String(byte[])
http://www.mkyong.com/java/how-do-convert-byte-array-to-string-in-java/
http://www.tutorialspoint.com/java/java_string_getbytes.htm
'Java' 카테고리의 다른 글
역슬래쉬(\)는 탈출문자로 처리, 슬래쉬는 그냥 써도 된다. (0) | 2014.02.23 |
---|---|
[Java] int String 변환 (0) | 2014.02.21 |
[Java] 패키지 컴파일 (0) | 2014.02.11 |
[Java] list와 향상된 for문 (2) | 2014.02.09 |
[Java] 2차원 배열의 길이 (0) | 2014.02.08 |