{"id":347,"date":"2014-08-17T17:19:20","date_gmt":"2014-08-18T02:19:20","guid":{"rendered":"http:\/\/blog.box.kr\/?p=347"},"modified":"2014-08-17T17:19:20","modified_gmt":"2014-08-18T02:19:20","slug":"java%ec%97%90%ec%84%9c-string-%ec%9d%b8%ec%bd%94%eb%94%a9-%ed%99%95%ec%9d%b8%eb%b0%a9%eb%b2%95","status":"publish","type":"post","link":"https:\/\/blog.box.kr\/?p=347","title":{"rendered":"java\uc5d0\uc11c string \uc778\ucf54\ub529 \ud655\uc778\ubc29\ubc95"},"content":{"rendered":"<div class=\"titleWrap\">\n<h2><\/h2>\n<\/div>\n<div class=\"article\" style=\"color: #909090;\">\n<p>String word = s;<\/p>\n<p>System.out.println(&#8220;utf-8(1) : &#8221; + new String(word.getBytes(&#8220;utf-8&#8221;), &#8220;euc-kr&#8221;));<\/p>\n<p>System.out.println(&#8220;utf-8(2) : &#8221; + new String(word.getBytes(&#8220;utf-8&#8221;), &#8220;ksc5601&#8221;));<\/p>\n<p>System.out.println(&#8220;utf-8(3) : &#8221; + new String(word.getBytes(&#8220;utf-8&#8221;), &#8220;x-windows-949&#8221;));<\/p>\n<p>System.out.println(&#8220;utf-8(4) : &#8221; + new String(word.getBytes(&#8220;utf-8&#8221;), &#8220;iso-8859-1&#8221;));<\/p>\n<p>System.out.println(&#8220;iso-8859-1(1) : &#8221; + new String(word.getBytes(&#8220;iso-8859-1&#8221;), &#8220;euc-kr&#8221;));<\/p>\n<p>System.out.println(&#8220;iso-8859-1(2) : &#8221; + new String(word.getBytes(&#8220;iso-8859-1&#8221;), &#8220;ksc5601&#8221;));<\/p>\n<p>System.out.println(&#8220;iso-8859-1(3) : &#8221; + new String(word.getBytes(&#8220;iso-8859-1&#8221;), &#8220;x-windows-949&#8221;));<\/p>\n<p>System.out.println(&#8220;iso-8859-1(4) : &#8221; + new String(word.getBytes(&#8220;iso-8859-1&#8221;), &#8220;utf-8&#8221;));<\/p>\n<p>System.out.println(&#8220;euc-kr(1) : &#8221; + new String(word.getBytes(&#8220;euc-kr&#8221;), &#8220;ksc5601&#8221;));<\/p>\n<p>System.out.println(&#8220;euc-kr(2) : &#8221; + new String(word.getBytes(&#8220;euc-kr&#8221;), &#8220;utf-8&#8221;));<\/p>\n<p>System.out.println(&#8220;euc-kr(3) : &#8221; + new String(word.getBytes(&#8220;euc-kr&#8221;), &#8220;x-windows-949&#8221;));<\/p>\n<p>System.out.println(&#8220;euc-kr(4) : &#8221; + new String(word.getBytes(&#8220;euc-kr&#8221;), &#8220;iso-8859-1&#8221;));<\/p>\n<p>System.out.println(&#8220;ksc5601(1) : &#8221; + new String(word.getBytes(&#8220;ksc5601&#8221;), &#8220;euc-kr&#8221;));<\/p>\n<p>System.out.println(&#8220;ksc5601(2) : &#8221; + new String(word.getBytes(&#8220;ksc5601&#8221;), &#8220;utf-8&#8221;));<\/p>\n<p>System.out.println(&#8220;ksc5601(3) : &#8221; + new String(word.getBytes(&#8220;ksc5601&#8221;), &#8220;x-windows-949&#8221;));<\/p>\n<p>System.out.println(&#8220;ksc5601(4) : &#8221; + new String(word.getBytes(&#8220;ksc5601&#8221;), &#8220;iso-8859-1&#8221;));<\/p>\n<p>System.out.println(&#8220;x-windows-949(1) : &#8221; + new String(word.getBytes(&#8220;x-windows-949&#8221;), &#8220;euc-kr&#8221;));<\/p>\n<p>System.out.println(&#8220;x-windows-949(2) : &#8221; + new String(word.getBytes(&#8220;x-windows-949&#8221;), &#8220;utf-8&#8221;));<\/p>\n<p>System.out.println(&#8220;x-windows-949(3) : &#8221; + new String(word.getBytes(&#8220;x-windows-949&#8221;), &#8220;ksc5601&#8221;));<\/p>\n<p>System.out.println(&#8220;x-windows-949(4) : &#8221; + new String(word.getBytes(&#8220;x-windows-949&#8221;), &#8220;iso-8859-1&#8221;));<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>String word = s; System.out.println(&#8220;utf-8(1) : &#8221; + new String(word.getBytes(&#8220;utf-8&#8221;), &#8220;euc-kr&#8221;)); System.out.println(&#8220;utf-8(2) : &#8221; + new String(word.getBytes(&#8220;utf-8&#8221;), &#8220;ksc5601&#8221;)); System.out.println(&#8220;utf-8(3) : &#8221; + new String(word.getBytes(&#8220;utf-8&#8221;), &#8220;x-windows-949&#8221;)); System.out.println(&#8220;utf-8(4) : &#8221; + new String(word.getBytes(&#8220;utf-8&#8221;), &#8220;iso-8859-1&#8221;)); System.out.println(&#8220;iso-8859-1(1) : &#8221; + new String(word.getBytes(&#8220;iso-8859-1&#8221;), &#8220;euc-kr&#8221;)); System.out.println(&#8220;iso-8859-1(2) : &#8221; + new String(word.getBytes(&#8220;iso-8859-1&#8221;), &#8220;ksc5601&#8221;)); System.out.println(&#8220;iso-8859-1(3) : &#8221; + new String(word.getBytes(&#8220;iso-8859-1&#8221;), &#8220;x-windows-949&#8221;)); System.out.println(&#8220;iso-8859-1(4) : &#8221; + new String(word.getBytes(&#8220;iso-8859-1&#8221;), &#8220;utf-8&#8221;)); System.out.println(&#8220;euc-kr(1) : &#8221; + new String(word.getBytes(&#8220;euc-kr&#8221;), &#8220;ksc5601&#8221;)); System.out.println(&#8220;euc-kr(2) : &#8221; + new String(word.getBytes(&#8220;euc-kr&#8221;), &#8220;utf-8&#8221;)); System.out.println(&#8220;euc-kr(3) : &#8221; + new String(word.getBytes(&#8220;euc-kr&#8221;), &#8220;x-windows-949&#8221;)); System.out.println(&#8220;euc-kr(4) : &#8221; + new String(word.getBytes(&#8220;euc-kr&#8221;), &#8220;iso-8859-1&#8221;)); System.out.println(&#8220;ksc5601(1) : &#8221; + new String(word.getBytes(&#8220;ksc5601&#8221;), &#8220;euc-kr&#8221;)); System.out.println(&#8220;ksc5601(2) : &#8221; + new String(word.getBytes(&#8220;ksc5601&#8221;), &#8220;utf-8&#8221;)); System.out.println(&#8220;ksc5601(3) : &#8221; + new String(word.getBytes(&#8220;ksc5601&#8221;), &#8220;x-windows-949&#8221;)); System.out.println(&#8220;ksc5601(4) : &#8221; + new String(word.getBytes(&#8220;ksc5601&#8221;), &#8220;iso-8859-1&#8221;)); System.out.println(&#8220;x-windows-949(1) : &#8221; + new String(word.getBytes(&#8220;x-windows-949&#8221;), &#8220;euc-kr&#8221;)); System.out.println(&#8220;x-windows-949(2) : &#8221; + new String(word.getBytes(&#8220;x-windows-949&#8221;), &#8220;utf-8&#8221;)); System.out.println(&#8220;x-windows-949(3) : &#8221; + new String(word.getBytes(&#8220;x-windows-949&#8221;), &#8220;ksc5601&#8221;)); System.out.println(&#8220;x-windows-949(4) : &#8221; + new String(word.getBytes(&#8220;x-windows-949&#8221;), &#8220;iso-8859-1&#8221;)); &nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"ngg_post_thumbnail":0,"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[15,7],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5q9Zn-5B","jetpack-related-posts":[{"id":212,"url":"https:\/\/blog.box.kr\/?p=212","url_meta":{"origin":347,"position":0},"title":"JAVA &#8211; \ud55c\uae00 \uc778\ucf54\ub529 \ubcc0\ud658 \uccb4\ud06c \ud55c\ubc29\uc5d0 \ub05d\ub0b4\uae30\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0","date":"2014-07-22","format":false,"excerpt":"String word = \"\ubb34\uad81\ud654 \uaf43\uc774 \ud53c\uc5c8\uc2b5\ub2c8\ub2e4.\"; System.out.println(\"utf-8 -> euc-kr\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : \" + new String(word.getBytes(\"utf-8\"), \"euc-kr\")); System.out.println(\"utf-8 -> ksc5601\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : \" + new String(word.getBytes(\"utf-8\"), \"ksc5601\")); System.out.println(\"utf-8 -> x-windows-949 : \" + new String(word.getBytes(\"utf-8\"), \"x-windows-949\")); System.out.println(\"utf-8 -> iso-8859-1\u00a0\u00a0\u00a0 : \" + new String(word.getBytes(\"utf-8\"), \"iso-8859-1\")); System.out.println(\"iso-8859-1 -> euc-kr\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : \" + new String(word.getBytes(\"iso-8859-1\"),\u2026","rel":"","context":"In &quot;JAVA&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":214,"url":"https:\/\/blog.box.kr\/?p=214","url_meta":{"origin":347,"position":1},"title":"UTF-8 \uc778\ucf54\ub529\ub41c \ud30c\uc77c \uc77d\uace0 EUC-KR \ubcc0\uacbd encoded file read","date":"2014-07-22","format":false,"excerpt":"package com.javawide.files; import java.io.*; public class UTF8Reader { public static void main(String[] args) { UTF8Reader reader = new UTF8Reader(); try { String utf8String = reader.readFully(\"C:\/utf8test.txt\"); System.out.println(utf8String); System.out.println(new String(utf8String.getBytes(), \"EUC-KR\")); } catch (Exception e) { e.printStackTrace(); } } \u00a0public String readFully(String fileName) throws Exception { File f = new File(fileName); if(!f.exists())\u2026","rel":"","context":"In &quot;JAVA&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":154,"url":"https:\/\/blog.box.kr\/?p=154","url_meta":{"origin":347,"position":2},"title":"Reading a UTF-8 Encoded File","date":"2014-07-06","format":false,"excerpt":"public static String parseTemplate(String templatePath) { File aFile = new File(templatePath); InputStreamReader reader = null; String template; StringBuffer temp = new StringBuffer(); int counter = 0; try { FileInputStream inStream = new FileInputStream(aFile); reader = new InputStreamReader(inStream, \"utf8\"); BufferedReader inBuf = new BufferedReader(reader); while ((template=inBuf.readLine()) != null) { if(counter ==\u2026","rel":"","context":"In &quot;JAVA&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":583,"url":"https:\/\/blog.box.kr\/?p=583","url_meta":{"origin":347,"position":3},"title":"java\ub85c unzip","date":"2015-01-28","format":false,"excerpt":"http:\/\/sourceforge.net\/projects\/jazzlib\/ \u00a0 Java comes with \u201cjava.util.zip\u201d library to perform data compression in ZIp format. The overall concept is quite straightforward. Read file with \u201cFileInputStream\u201d Add the file name to \u201cZipEntry\u201d and output it to \u201cZipOutputStream\u201c 1. Simple ZIP example Read a file \u201cC:\\spy.log\u201d and compress it into a zip file\u2026","rel":"","context":"In &quot;JAVA&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":450,"url":"https:\/\/blog.box.kr\/?p=450","url_meta":{"origin":347,"position":4},"title":"[\ud38c]Gmail SMTP Server\ub97c \uc774\uc6a9\ud55c \uba54\uc77c\uc804\uc1a1 \uc608\uc81c","date":"2014-12-18","format":false,"excerpt":"Gmail SMTP Server\ub97c \uc774\uc6a9\ud55c \uba54\uc77c\uc804\uc1a1 \uc608\uc81c (\ubb34\ub8cc SMTP & Authentication) http:\/\/unionbaby.tistory.com\/category\/+%20Programer\/*%20java?page=2 + Programer\/* java Gmail, Authentication in JavaMail JavaMail 1.4.1:http:\/\/java.sun.com\/products\/javamail\/downloads\/index.html JAF 1.1.1: http:\/\/java.sun.com\/products\/javabeans\/jaf\/downloads\/index.html \u00a0 Gmail.java import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; import java.io.*; import java.util.*; import java.security.Security; public class Gmail { public static void main(String[] args) { Properties p =\u2026","rel":"","context":"In &quot;JAVA&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":148,"url":"https:\/\/blog.box.kr\/?p=148","url_meta":{"origin":347,"position":5},"title":"\ud55c WAS \uc11c\ubc84\uc5d0\uc11c UTF-8 \uacfc EUC-KR \ub458\ub2e4 \uc9c0\uc6d0\ud558\uae30..","date":"2014-07-03","format":false,"excerpt":"\ud55c \uc6f9\uc11c\ubc84\uc5d0 UTF-8\uacfc EUC-KR \uc744 \uac19\uc774 \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 TIP\uc774 \uc788\uae34 \ud569\ub2c8\ub2e4...\uc2e4\uc81c\ub85c \uc0ac\uc6a9\ud558\uace0 \uc788\uc73c\ub098, \ud14c\uc2a4\ud2b8\ub294 \uaf2d \ud574\ubcf4\uc138\uc694..\u00a0\uc0ac\uc6a9\ud658\uacbd\uc740 \ub9ac\ub205\uc2a4(CENTOS)+APACH+TOMCAT+SPRING2.5\u00a0web.xml \uc5d0\uc11c \ud544\ud130\ub97c \ucd94\uac00\ud574\uc8fc\ub294\ub370\uc694 UTF-8\uc6a9\uacfc EUC-KR \ub458\ub2e4 \ud544\ud130\ub97c \ucd94\uac00\ud574\uc90d\ub2c8\ub2e4.\u00a0<filter>\u00a0<display-name>encodingFilter<\/display-name><filter-name>encodingFilter<\/filter-name>\u00a0<filter-class>org.springframework.web.filter.CharacterEncodingFilter<\/filter-class>\u00a0<init-param><param-name>encoding<\/param-name><param-value>UTF-8<\/param-value>\u00a0<\/init-param>\u00a0<\/filter>\u00a0<filter>\u00a0<display-name>euc_kr_encodingFilter<\/display-name><filter-name>euc_kr_encodingFilter<\/filter-name>\u00a0<filter-class>org.springframework.web.filter.CharacterEncodingFilter<\/filter-class>\u00a0<init-param><param-name>encoding<\/param-name><param-value>EUC-KR<\/param-value><\/init-param>\u00a0<\/filter>\u00a0 <filter-mapping> <filter-name>encodingFilter<\/filter-name> <url-pattern>*.do<\/url-pattern> <\/filter-mapping> <filter-mapping> <filter-name>euc_kr_encodingFilter<\/filter-name> <url-pattern>*.do2<\/url-pattern> <\/filter-mapping> <servlet> <servlet-name>dispatcher<\/servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet<\/servlet-class> <load-on-startup>2<\/load-on-startup> <\/servlet> <servlet-mapping> <servlet-name>dispatcher<\/servlet-name> <url-pattern>*.do<\/url-pattern> <\/servlet-mapping> <servlet-mapping> <servlet-name>dispatcher<\/servlet-name> <url-pattern>*.do2<\/url-pattern> <\/servlet-mapping> \u00a0 \u00a0 \uadf8\ub9ac\uace0\u2026","rel":"","context":"In &quot;WAS, Servet Containers&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/347"}],"collection":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=347"}],"version-history":[{"count":0,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/347\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}