{"id":172,"date":"2019-02-24T23:36:04","date_gmt":"2019-02-24T14:36:04","guid":{"rendered":"https:\/\/took.jp\/?p=172"},"modified":"2020-06-26T17:23:59","modified_gmt":"2020-06-26T08:23:59","slug":"post-172","status":"publish","type":"post","link":"https:\/\/took.jp\/tech-blog\/post-172\/","title":{"rendered":"\u3010Java\u6b63\u898f\u8868\u73fe\u3011 \u7981\u6b62\u6587\u5b57\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b \u5224\u5b9a\u3059\u308b"},"content":{"rendered":"<p>\u3053\u306e\u30af\u30e9\u30b9\u306f\u79c1\u304cJava\u306e\u52c9\u5f37\u3092\u59cb\u3081\u305f\u3068\u304d\u306b\u3001\u521d\u3081\u3066\u66f8\u3044\u305f\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u305f\u30af\u30e9\u30b9\u3067\u3059\u306e\u3067\u3001\u304a\u304b\u3057\u306a\u90e8\u5206\u304c\u3042\u308c\u3070\u3001\u3053\u3063\u305d\u308a\u3068\u6307\u6458\u3057\u3066\u304f\u3060\u3055\u3044\u7b11<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30af\u30e9\u30b9\u306b\u95a2\u3057\u3066\u306e\u8aac\u660e<\/h2>\n<p>\u3053\u306e\u30af\u30e9\u30b9\u306f\u3001Web\u30b5\u30a4\u30c8\u5236\u4f5c\u3092\u3057\u3066\u3044\u305f\u6642\u306b\u4f7f\u7528\u3057\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u753b\u9762\u3067\u3001\u30bf\u30a4\u30c8\u30eb\u306e\u6587\u5b57\u6570\u3001\u6295\u7a3f\u8a18\u4e8b\u5185\u5bb9\u306e\u6587\u5b57\u6570\u306b\u5236\u9650\u3092\u304b\u3051\u3001<\/p>\n<p>\u305d\u306e\u5185\u5bb9\u306b\u7981\u6b62\u6587\u5b57\u304c\u542b\u307e\u308c\u3066\u3044\u305f\u5834\u5408\u306b\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8fd4\u3059\u3068\u3044\u3046\u30af\u30e9\u30b9\u3067\u3059\u3002<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-medium wp-image-182\" src=\"https:\/\/took.jp\/wp-content\/uploads\/2019\/02\/seikihyougen-300x205.jpg\" alt=\"\" width=\"300\" height=\"205\" srcset=\"https:\/\/took.jp\/tech-blog\/wp-content\/uploads\/2019\/02\/seikihyougen-300x205.jpg 300w, https:\/\/took.jp\/tech-blog\/wp-content\/uploads\/2019\/02\/seikihyougen.jpg 498w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u3053\u308c\u304b\u3089\u52c9\u5f37\u3092\u59cb\u3081\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u521d\u5fc3\u8005\u306e\u65b9\u306b\u306f\u3001\u3068\u3066\u3082\u8aad\u307f\u3084\u3059\u304f\u306a\u3063\u3066\u3044\u308b\u3068\u601d\u3046\u306e\u3067\u3001\u52c9\u5f37\u7528\u306b\u3069\u3046\u305e\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<pre class=\"line-numbers\"><code class=\"language-java\">package jp.took.util;import java.util.ArrayList;\r\nimport java.util.List;\r\nimport java.util.regex.Matcher;\r\nimport java.util.regex.Pattern;public class InputChecker {\/**\r\n*\u6295\u7a3f\u8a18\u4e8b\u5185\u90e8\u306b\u5165\u529b\u3057\u3066\u306f\u3044\u3051\u306a\u3044\u6587\u5b57\u304c\u5b58\u5728\u3057\u306a\u3044\u304b\u3092\u78ba\u8a8d\u3057\u3001\u3082\u3057\u542b\u307e\u308c\u3066\u3044\u305f\u5834\u5408\u306f\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8fd4\u3057\u307e\u3059\u3002\r\n* \u307e\u305f\u3001\u6587\u5b57\u6570\u306e\u5236\u9650\u3082\u4e00\u7dd2\u306b\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\r\n* \u7981\u6b62\u6587\u5b57\u3092\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\u306f\u3001word\u914d\u5217\u306b\u7981\u6b62\u3057\u305f\u3044\u6587\u5b57\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002\r\n*\/\r\n\/\/\u7981\u6b62\u6587\u5b57\u3001\u6587\u5b57\u6570\u5236\u9650\r\npublic List&lt;String&gt; doCheck(String title,String introduction){\r\nList&lt;String&gt; stringList = new ArrayList&lt;String&gt;();\r\nString value[] = {\"\u30bf\u30a4\u30c8\u30eb\",\"\u7d39\u4ecb\u6587\"};\r\nString contents[] = {title,introduction};\/\/\u5224\u5b9a\u3059\u308b\u6587\u5b57\u5217\r\nfor(int o = 0;o&lt;2;o++) {\/\/\u30bf\u30a4\u30c8\u30eb(\u6700\u5c0f\u3001\u6700\u5927)\u3001\u7d39\u4ecb\u6587(\u6700\u5c0f\u3001\u6700\u5927)\r\nint restriction[][] = {{1,15},{30,150}};if(contents[o].length() &lt; restriction[o][0] || contents[o].length() &gt; restriction[o][1]){\r\nstringList.add(value[o] + \"\u306f\" + restriction[o][0] + \"\u6587\u5b57\u4ee5\u4e0a\" + restriction[o][1] + \"\u6587\u5b57\u4ee5\u4e0b\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\");\r\n}\r\n\/\/\u7981\u6b62\u6587\u5b57\u7a2e\u3092\u5897\u3084\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u3053\u306e\u914d\u5217\u5185\u306b\u8981\u7d20\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\r\nString word[] = {\"\u7981\u6b62\u6587\u5b571\",\"\u7981\u6b62\u6587\u5b572\",\"\u7981\u6b62\u6587\u5b573\",\"\u7981\u6b62\u6587\u5b574\"};\r\n\r\nfor(String i:word){\r\nStringBuilder sb = new StringBuilder();\r\nsb.append(\"^(.*\");\r\nsb.append(i);\r\nsb.append(\").*\");\r\nPattern p = Pattern.compile(sb.toString());\r\nMatcher m = p.matcher(contents[o]);\r\n\r\n\/\/\u7981\u6b62\u6587\u5b57\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u5224\u5b9a\u3059\u308b\r\nif(m.find()) {\r\nstringList.add(\"\u7981\u6b62\u6587\u5b57\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002\");\r\nreturn stringList;\r\n}\r\n}\r\n}\r\nreturn stringList;\r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h2>\u95a2\u9023\u66f8\u7c4d<\/h2>\n<div id=\"rinkerid2253\" class=\"yyi-rinker-contents  yyi-rinker-postid-2253 yyi-rinker-img-m yyi-rinker-catid-62 yyi-rinker-catid-70 yyi-rinker-catid-87 \">\n\t<div class=\"yyi-rinker-box\">\n\t\t<div class=\"yyi-rinker-image\">\n\t\t\t\t\t\t\t<a href=\"https:\/\/www.amazon.co.jp\/dp\/B07ZQWKL2Q?tag=tookblog-22&#038;linkCode=ogi&#038;th=1&#038;psc=1\" rel=\"nofollow\" class=\"yyi-rinker-tracking\"  data-click-tracking=\"amazon_img 2253 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308bJava\u5165\u9580 \u7b2c3\u7248 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308b\u30b7\u30ea\u30fc\u30ba\" data-vars-click-id=\"amazon_img 2253 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308bJava\u5165\u9580 \u7b2c3\u7248 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308b\u30b7\u30ea\u30fc\u30ba\"><img decoding=\"async\" src=\"https:\/\/m.media-amazon.com\/images\/I\/51CBaBs20IL._SL160_.jpg\"  width=\"112\" height=\"160\" class=\"yyi-rinker-main-img\" style=\"border: none;\"><\/a>\t\t\t\t\t<\/div>\n\t\t<div class=\"yyi-rinker-info\">\n\t\t\t<div class=\"yyi-rinker-title\">\n\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/www.amazon.co.jp\/dp\/B07ZQWKL2Q?tag=tookblog-22&#038;linkCode=ogi&#038;th=1&#038;psc=1\" rel=\"nofollow\" class=\"yyi-rinker-tracking\" data-click-tracking=\"amazon_title 2253 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308bJava\u5165\u9580 \u7b2c3\u7248 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308b\u30b7\u30ea\u30fc\u30ba\" data-vars-amp-click-id=\"amazon_title 2253 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308bJava\u5165\u9580 \u7b2c3\u7248 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308b\u30b7\u30ea\u30fc\u30ba\" >\u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308bJava\u5165\u9580 \u7b2c3\u7248 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308b\u30b7\u30ea\u30fc\u30ba<\/a>\t\t\t\t\t\t\t<\/div>\n\t\t\t<div class=\"yyi-rinker-detail\">\n\t\t\t\t\t\t\t<div class=\"credit-box\">created by&nbsp;<a href=\"https:\/\/oyakosodate.com\/rinker\/\" rel=\"nofollow noopener\" target=\"_blank\" >Rinker<\/a><\/div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"price-box\">\n\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<ul class=\"yyi-rinker-links\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<li class=\"amazonkindlelink\">\n\t\t\t\t\t\t<a href=\"https:\/\/www.amazon.co.jp\/dp\/B07ZQWKL2Q?tag=tookblog-22&amp;linkCode=ogi&amp;th=1&amp;psc=1\" rel=\"nofollow\" class=\"yyi-rinker-link yyi-rinker-tracking\"  data-click-tracking=\"amazon_kindle 2253 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308bJava\u5165\u9580 \u7b2c3\u7248 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308b\u30b7\u30ea\u30fc\u30ba\"  data-vars-amp-click-id=\"amazon_kindle 2253 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308bJava\u5165\u9580 \u7b2c3\u7248 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308b\u30b7\u30ea\u30fc\u30ba\">Kindle<\/a>\t\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t                    <li class=\"amazonlink\">\n\t\t\t\t\t\t<a href=\"https:\/\/www.amazon.co.jp\/dp\/B07ZQWKL2Q?tag=tookblog-22&amp;linkCode=ogi&amp;th=1&amp;psc=1\" rel=\"nofollow\" class=\"yyi-rinker-link yyi-rinker-tracking\"  data-click-tracking=\"amazon 2253 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308bJava\u5165\u9580 \u7b2c3\u7248 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308b\u30b7\u30ea\u30fc\u30ba\"  data-vars-amp-click-id=\"amazon 2253 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308bJava\u5165\u9580 \u7b2c3\u7248 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308b\u30b7\u30ea\u30fc\u30ba\">Amazon<\/a>\t\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<li class=\"rakutenlink\">\n\t\t\t\t\t\t<a href=\"https:\/\/hb.afl.rakuten.co.jp\/hgc\/1c036c69.607c96c1.1c036c6a.5e5b82db\/Rinker_o_20200626172355?pc=https%3A%2F%2Fsearch.rakuten.co.jp%2Fsearch%2Fmall%2FJava%2F%3Ff%3D1%26grp%3Dproduct&amp;m=https%3A%2F%2Fsearch.rakuten.co.jp%2Fsearch%2Fmall%2FJava%2F%3Ff%3D1%26grp%3Dproduct\" rel=\"nofollow\" class=\"yyi-rinker-link yyi-rinker-tracking\"  data-click-tracking=\"rakuten 2253 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308bJava\u5165\u9580 \u7b2c3\u7248 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308b\u30b7\u30ea\u30fc\u30ba\"  data-vars-amp-click-id=\"rakuten 2253 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308bJava\u5165\u9580 \u7b2c3\u7248 \u30b9\u30c3\u30ad\u30ea\u308f\u304b\u308b\u30b7\u30ea\u30fc\u30ba\">\u697d\u5929\u5e02\u5834<\/a>\t\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/ul>\n\t\t\t\t\t<\/div>\n\t<\/div>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u30af\u30e9\u30b9\u306f\u79c1\u304cJava\u306e\u52c9\u5f37\u3092\u59cb\u3081\u305f\u3068\u304d\u306b\u3001\u521d\u3081\u3066\u66f8\u3044\u305f\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u305f\u30af\u30e9\u30b9\u3067\u3059\u306e\u3067\u3001\u304a\u304b\u3057\u306a\u90e8\u5206\u304c\u3042\u308c\u3070\u3001\u3053\u3063\u305d\u308a\u3068\u6307\u6458\u3057\u3066\u304f\u3060\u3055\u3044\u7b11 &nbsp; \u30af\u30e9\u30b9\u306b\u95a2\u3057\u3066\u306e\u8aac\u660e \u3053\u306e\u30af\u30e9\u30b9\u306f\u3001Web\u30b5\u30a4\u30c8\u5236\u4f5c\u3092\u3057\u3066\u3044\u305f\u6642\u306b\u4f7f\u7528\u3057\u3066\u3044\u307e\u3057\u305f\u3002\u2026<\/p>\n","protected":false},"author":3,"featured_media":2017,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62,70,87],"tags":[],"class_list":["post-172","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-it","category-java","category-87"],"_links":{"self":[{"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/posts\/172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/comments?post=172"}],"version-history":[{"count":0,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/posts\/172\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/media\/2017"}],"wp:attachment":[{"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/media?parent=172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/categories?post=172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/tags?post=172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}