{"id":690,"date":"2004-07-14T16:00:00","date_gmt":"2004-07-14T07:00:00","guid":{"rendered":"\/?p=690"},"modified":"2004-07-14T16:00:00","modified_gmt":"2004-07-14T07:00:00","slug":"tool","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/690.html","title":{"rendered":"Tool"},"content":{"rendered":"<p>\n\u3061\u3087\u3063\u3068\u3057\u305f\u30c4\u30fc\u30eb\u3092\u4f5c\u3063\u3066\u307f\u305f\u3002\n<\/p>\n<p>\nfml\u3067\u4f5c\u3063\u305fML\u306e\u30b9\u30d7\u30fc\u30eb\u306b\u3042\u308b\u30e1\u30fc\u30eb\u304b\u3089Date, From, Subject \u306e\u60c5\u5831\u3092\u629c\u304d\u3060\u3057\u3066\u4e00\u89a7\u306b\u3059\u308b\u305f\u3081\u306b\u4f7f\u3046\u3002Linux\u3067\u52d5\u4f5c\u3059\u308b\u3002\n<\/p>\n<p><div class=\"code\">$ .\/create.sh\n<\/div>\n<\/p>\n<p><!--more--><\/p>\n<p>\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u3053\u3093\u306a\u611f\u3058\u3002\u3053\u3053\u3067\u306f\u3001work\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3084out\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u3042\u3089\u304b\u3058\u3081\u4f5c\u3063\u3066\u3042\u308b\u3002<\/p>\n<div class=\"code\">#! \/bin\/sh<br \/>\nSPOOL=&#8221;ml\/spool&#8221;<br \/>\ncount=1<br \/>\nwhile test &#8220;$count&#8221; -lt &#8216;2933&#8217;<br \/>\n  do<br \/>\n  \/usr\/local\/j2sdk1.4.2_01\/bin\/java Tool01 $SPOOL\/$count | nkf -m &gt; work\/$count<br \/>\n  \/usr\/local\/j2sdk1.4.2_01\/bin\/java Tool02 work\/$count &gt; out\/$count<br \/>\n  cat out\/$count &gt;&gt; result.csv<br \/>\n  count=`expr $count + 1`<br \/>\n  done\n<\/div>\n<\/p>\n<p>Tool01 \u30af\u30e9\u30b9\u306f\u6b21\u306e\u901a\u308a<\/p>\n<div class=\"code\">import java.io.*;<\/p>\n<p>public class Tool01 {<br \/>\n    public static void main(String[] args) throws Exception {<br \/>\n\tif (args.length &lt; 1) return;<\/p>\n<p>\tFile iFile = new File(args[0]);<\/p>\n<p>        BufferedReader r = new BufferedReader(<br \/>\n\t\t\t      new InputStreamReader(<br \/>\n\t\t\t\tnew FileInputStream(iFile)));<br \/>\n\tString line;<br \/>\n        while ( (line = r.readLine()) != null &#038;&#038; line.length() &gt; 0) {<br \/>\n\t    if (line.startsWith(&#8220;Date: &#8220;) ||<br \/>\n\t        line.startsWith(&#8220;From: &#8220;) ) {<br \/>\n\t\tSystem.out.println(line);<br \/>\n\t    } else if (line.startsWith(&#8220;Subject: &#8220;) ) {<br \/>\n\t\tString line2 = r.readLine();<br \/>\n\t\tif  (line2 == null || line2.length() &lt;= 0) {<br \/>\n\t\t} else {<br \/>\n\t\t    System.out.println(line);<br \/>\n\t\t    System.out.println(line2);<br \/>\n\t\t}<br \/>\n\t    }<br \/>\n\t}<br \/>\n    }<br \/>\n}<\/p><\/div>\n<\/p>\n<p>Tool02 \u30af\u30e9\u30b9\u306f\u6b21\u306e\u901a\u308a<\/p>\n<div class=\"code\">import java.io.*;<\/p>\n<p>public class Tool02 {<br \/>\n    public static void main(String[] args) throws Exception {<br \/>\n\tString SEP = &#8220;|&#8221;;<br \/>\n\tif (args.length &lt; 1) return;<br \/>\n\tif (args.length == 2) SEP = args[1];<br \/>\n\tFile iFile = new File(args[0]);<\/p>\n<p>        BufferedReader r = new BufferedReader(<br \/>\n\t\t\t      new InputStreamReader(<br \/>\n\t\t\t\tnew FileInputStream(iFile)));<br \/>\n\tString line;<br \/>\n        while ( (line = r.readLine()) != null &#038;&#038; line.length() &gt; 0) {<br \/>\n\t    if (line.startsWith(&#8220;Date: &#8220;) ||<br \/>\n\t        line.startsWith(&#8220;From: &#8220;) ) {<br \/>\n\t\tSystem.out.print(line+SEP);<br \/>\n\t    } else if (line.startsWith(&#8220;Subject: &#8220;) ) {<br \/>\n\t\tString line2 = r.readLine();<br \/>\n\t\tif  (line2 == null || line2.length() &lt;= 0) {<br \/>\n\t\t} else {<br \/>\n\t\t    System.out.println(line+line2);<br \/>\n\t\t}<br \/>\n\t    }<br \/>\n\t}<br \/>\n    }<br \/>\n}\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u3061\u3087\u3063\u3068\u3057\u305f\u30c4\u30fc\u30eb\u3092\u4f5c\u3063\u3066\u307f\u305f\u3002 fml\u3067\u4f5c\u3063\u305fML\u306e\u30b9\u30d7\u30fc\u30eb\u306b\u3042\u308b\u30e1\u30fc\u30eb\u304b\u3089Date, From, Subject \u306e\u60c5\u5831\u3092\u629c\u304d\u3060\u3057\u3066\u4e00\u89a7\u306b\u3059\u308b\u305f\u3081\u306b\u4f7f\u3046\u3002Linux\u3067\u52d5\u4f5c\u3059\u308b\u3002 $ .\/create.sh<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-690","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=690"}],"version-history":[{"count":0,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/690\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}