{"id":208,"date":"2014-07-21T21:34:44","date_gmt":"2014-07-22T06:34:44","guid":{"rendered":"http:\/\/blog.box.kr\/?p=208"},"modified":"2014-07-21T21:34:44","modified_gmt":"2014-07-22T06:34:44","slug":"%ec%9e%90%eb%b0%94-%ed%86%a0%ed%81%b0-%ed%86%a0%ed%81%ac%eb%82%98%ec%9d%b4%ec%a0%b8stringtokenizer%eb%a1%9c-%ed%8c%8c%ec%9d%bc%ec%9e%85%eb%a0%a5-%ed%8c%8c%ec%9d%bc%ec%b6%9c%eb%a0%a5","status":"publish","type":"post","link":"https:\/\/blog.box.kr\/?p=208","title":{"rendered":"\uc790\ubc14 \ud1a0\ud070 \ud1a0\ud06c\ub098\uc774\uc838(StringTokenizer)\ub85c \ud30c\uc77c\uc785\ub825 \ud30c\uc77c\ucd9c\ub825"},"content":{"rendered":"<p style=\"color: #717171;\">import java.io.*;<br \/>\nimport java.util.*;<\/p>\n<p style=\"color: #717171;\">public class A<br \/>\n{<\/p>\n<p style=\"color: #717171;\">\u00a0 public static void main(String[] args) throws IOException{<br \/>\nFileInputStream fin = new FileInputStream(&#8220;a.txt&#8221;);<br \/>\nBufferedReader in =\u00a0 new BufferedReader((new InputStreamReader(fin, &#8220;UTF-8&#8221;)));<br \/>\nBufferedWriter Bout =\u00a0 new BufferedWriter(new FileWriter(&#8220;B.txt&#8221;));<br \/>\nBufferedWriter Cout =\u00a0 new BufferedWriter(new FileWriter(&#8220;C.txt&#8221;));<\/p>\n<p style=\"color: #717171;\">\u00a0\u00a0\u00a0 String temp;<br \/>\nint key = 0;<br \/>\nwhile((temp = in.readLine()) != null) {<br \/>\nif (temp.indexOf(&#8220;\ub860\ub300\ud559\uad50\ub2e4&#8221;)&gt;0)<br \/>\n{<br \/>\nkey = 0;<br \/>\n}else if (temp.indexOf(&#8220;\ub860\uc804\ubb38\ub300\ud559\uad50&#8221;)&gt;0)<br \/>\n<span id=\"callbacknestwindjasitistorycom336174\"><\/span>\u00a0\u00a0 {<br \/>\nkey = 1;<br \/>\n}<br \/>\nStringTokenizer st = new StringTokenizer(temp,&#8221;:,&#8221;);<br \/>\nString[] tempstr = new String[st.countTokens()];<br \/>\nint cnttoken = st.countTokens();<br \/>\nint i = 0;<br \/>\nif(key==0) {<br \/>\nwhile(st.hasMoreTokens()) {<br \/>\ntemp=st.nextToken();<br \/>\ntemp.trim();<br \/>\ntempstr[i]=temp;<br \/>\nif(cnttoken &gt; 1 &amp;&amp; i != 0) {<br \/>\nBout.write(tempstr[0]);<br \/>\nBout.write(&#8220;,&#8221;);<br \/>\nBout.write(tempstr[i]);<br \/>\nBout.newLine();<br \/>\n}<br \/>\ni++;<br \/>\n}<br \/>\n}<br \/>\nif(key==1) {<br \/>\nwhile(st.hasMoreTokens()) {<br \/>\ntemp=st.nextToken();<br \/>\ntemp.trim();<br \/>\ntempstr[i]=temp;<br \/>\nif(cnttoken &gt; 1 &amp;&amp; i != 0) {<br \/>\nCout.write(tempstr[0]);<br \/>\nCout.write(&#8220;,&#8221;);<br \/>\nCout.write(tempstr[i]);<br \/>\nCout.newLine();<br \/>\n}<br \/>\ni++;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\nin.close();<br \/>\nBout.close();<br \/>\nCout.close();<br \/>\n}<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>import java.io.*; import java.util.*; public class A { \u00a0 public static void main(String[] args) throws IOException{ FileInputStream fin = new FileInputStream(&#8220;a.txt&#8221;); BufferedReader in =\u00a0 new BufferedReader((new InputStreamReader(fin, &#8220;UTF-8&#8221;))); BufferedWriter Bout =\u00a0 new BufferedWriter(new FileWriter(&#8220;B.txt&#8221;)); BufferedWriter Cout =\u00a0 new BufferedWriter(new FileWriter(&#8220;C.txt&#8221;)); \u00a0\u00a0\u00a0 String temp; int key = 0; while((temp = in.readLine()) != null) { if (temp.indexOf(&#8220;\ub860\ub300\ud559\uad50\ub2e4&#8221;)&gt;0) { key = 0; }else if (temp.indexOf(&#8220;\ub860\uc804\ubb38\ub300\ud559\uad50&#8221;)&gt;0) \u00a0\u00a0 { key = 1; } StringTokenizer st = new StringTokenizer(temp,&#8221;:,&#8221;); String[] tempstr = new String[st.countTokens()]; int cnttoken = st.countTokens(); int i = 0; if(key==0) { while(st.hasMoreTokens()) { temp=st.nextToken(); temp.trim(); tempstr[i]=temp; if(cnttoken &gt; 1 &amp;&amp; i != 0) { Bout.write(tempstr[0]); Bout.write(&#8220;,&#8221;); Bout.write(tempstr[i]); Bout.newLine(); } i++; } } if(key==1) { while(st.hasMoreTokens()) { temp=st.nextToken(); temp.trim(); tempstr[i]=temp; if(cnttoken &gt; 1 &amp;&amp; i != 0) { Cout.write(tempstr[0]); Cout.write(&#8220;,&#8221;); Cout.write(tempstr[i]); Cout.newLine(); } i++; } } } in.close(); Bout.close(); Cout.close(); } }<\/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-3m","jetpack-related-posts":[{"id":154,"url":"https:\/\/blog.box.kr\/?p=154","url_meta":{"origin":208,"position":0},"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":156,"url":"https:\/\/blog.box.kr\/?p=156","url_meta":{"origin":208,"position":1},"title":"reading text file with utf-8 encoding using java","date":"2014-07-06","format":false,"excerpt":"CASE 1. PrintStream out =newPrintStream(System.out,true,\"UTF-8\"); out.println(str); CASE 2. import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStreamReader;import java.io.UnsupportedEncodingException;publicclass test {publicstaticvoid main(String[] args){try{File fileDir =newFile(\"PATH_TO_FILE\");BufferedReader in =newBufferedReader(newInputStreamReader(newFileInputStream(fileDir),\"UTF8\"));String str;while((str = in.readLine())!=null){System.out.println(str);} in.close();}catch(UnsupportedEncodingException e){System.out.println(e.getMessage());}catch(IOException e){System.out.println(e.getMessage());}catch(Exception e){System.out.println(e.getMessage());}} }","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":208,"position":2},"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":214,"url":"https:\/\/blog.box.kr\/?p=214","url_meta":{"origin":208,"position":3},"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":487,"url":"https:\/\/blog.box.kr\/?p=487","url_meta":{"origin":208,"position":4},"title":"send file sftp java example","date":"2014-12-18","format":false,"excerpt":"public void send (String fileName) { String SFTPHOST = \"host:IP\"; int SFTPPORT = 22; String SFTPUSER = \"username\"; String SFTPPASS = \"password\"; String SFTPWORKINGDIR = \"file\/to\/transfer\"; Session session = null; Channel channel = null; ChannelSftp channelSftp = null; System.out.println(\"preparing the host information for sftp.\"); try { JSch jsch = new\u2026","rel":"","context":"In &quot;JAVA&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":625,"url":"https:\/\/blog.box.kr\/?p=625","url_meta":{"origin":208,"position":5},"title":"[\ud38c]JAVA \ud654\uc77c \uac10\uc2dc \ud504\ub85c\uadf8\ub7a8 \ub9cc\ub4e4\uae30.","date":"2015-03-21","format":false,"excerpt":"\uc77c\uc744 \ud558\ub2e4\ubcf4\uba74 \ud2b9\uc815 \ub514\ub809\ud1a0\ub9ac\ub97c \uac10\uc2dc\ud558\uc5ec \ud2b9\uc815 \uc870\uac74\uc774 \ub418\uba74 \uc874\uc7ac \ud558\ub294 \ud654\uc77c\uc744 \ucc98\ub9ac \ud558\ub294 \ud504\ub85c\uadf8\ub7a8\uc774 \ud544\uc694 \ud560\ub54c\uac00 \uc788\ub2e4. \u00a0 \ubcf4\ud1b5\uc740 C\/C++\ub85c \uc791\uc5c5 \ud558\ub294\ub370 \uc5b4\ucc0c\ub2e4 \ubcf4\ub2c8 \ubcf4\uac8c\ub41c \ube14\ub85c\uadf8\uc5d0\uc11c \uc5b4\ub5a4 \ubd84\uc774 JAVA\ub85c \ub9cc\ub4e4\uc5b4 \ub193\uc740\uac8c \uc788\uc5b4\uc11c \uac08\ubb34\ub9ac \ud55c\ub2e4. \u00a0 \u00a0 http:\/\/okky.kr\/article\/272376 \u00a0 Main.java public class Main { \/\/ file moved original public static final\u2026","rel":"","context":"In &quot;JAVA&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/208"}],"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=208"}],"version-history":[{"count":0,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/208\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}