{"id":984,"date":"2018-09-17T19:03:11","date_gmt":"2018-09-17T10:03:11","guid":{"rendered":"https:\/\/chat-messenger.com\/?p=984"},"modified":"2018-12-23T01:50:22","modified_gmt":"2018-12-22T16:50:22","slug":"inetaddress-getbyname","status":"publish","type":"post","link":"https:\/\/chat-messenger.com\/vi\/blog\/java\/inetdia-chi-getbyname","title":{"rendered":"Java l\u1ea5y t\u00ean m\u00e1y ch\u1ee7 t\u1eeb \u0111\u1ecba ch\u1ec9 IP"},"content":{"rendered":"<h2 class=\"common_title\"><a name=\"0\">Java l\u1ea5y t\u00ean m\u00e1y ch\u1ee7 t\u1eeb \u0111\u1ecba ch\u1ec9 IP<\/a> <strong>InetAddress.getByName()<\/strong><\/h2>\n<p>\n\u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh<strong>\u0111\u1ecba ch\u1ec9 IP<\/strong>c\u00f3<strong>t\u00ean m\u00e1y ch\u1ee7<\/strong>(<strong>t\u00ean may moc<\/strong>) \u0110\u00e2y l\u00e0 m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh m\u1eabu \u0111\u1ec3 l\u1ea5y.\n<\/p>\n<h2 class=\"common_title\"><a name=\"1\">ch\u01b0\u01a1ng tr\u00ecnh m\u1eabu<\/a><\/h2>\n<pre class=\"sample_src\">\/** * L\u1ea5y t\u00ean m\u00e1y ch\u1ee7 v\u1edbi \u0111\u1ecba ch\u1ec9 IP \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh. * \u0110\u1ecba ch\u1ec9 @param \u0110\u1ecba ch\u1ec9 IP * @return t\u00ean m\u00e1y ch\u1ee7 * *N\u1ebfu x\u1ea3y ra ngo\u1ea1i l\u1ec7 kh\u00f4ng mong mu\u1ed1n, chu\u1ed7i &quot;Unknownhost&quot; s\u1ebd \u0111\u01b0\u1ee3c tr\u1ea3 v\u1ec1. *\/ public static String getHostName(String address) { try { InetAddress iaddress = InetAddress.getByName(address); return iaddress.getHostName(); } Catch (Ngo\u1ea1i l\u1ec7 e) { e.printStackTrace(); } return &quot;UnknownHost&quot;; }\r\n<\/pre>\n<p><script type=\"text\/javascript\" src=\"https:\/\/chat-messenger.com\/js\/common.js?dd12sssas2223\" charset=\"UTF-8\"><\/script><br \/>\n<script type=\"text\/javascript\"> writePR(); <\/script><\/p>\n<h2 class=\"common_title\"><a name=\"2\">K\u1ebft qu\u1ea3 th\u1ef1c hi\u1ec7n<\/a><\/h2>\n<p>\u25c6V\u00ed d\u1ee5 th\u1ef1c thi<\/p>\n<pre class=\"sample_src\">public static void main(String[] args) { T\u00ean chu\u1ed7i = getHostName(&quot;66.249.89.99&quot;); System.out.println(&quot;T\u00ean m\u00e1y ch\u1ee7 = &#039;&quot;+name+&quot;&#039;&quot;); }\r\n<\/pre>\n<p>\u25c6K\u1ebft qu\u1ea3 \u0111\u1ea7u ra<\/p>\n<pre class=\"console\">t\u00ean m\u00e1y ch\u1ee7 = &#039;jp-in-f99.google.com&#039;\r\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>Java L\u1ea5y t\u00ean m\u00e1y ch\u1ee7 t\u1eeb \u0111\u1ecba ch\u1ec9 IP InetAddress.getByName() \u0110\u1ecba ch\u1ec9 IP \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh [\u2026]<\/p>","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":""},"categories":[19],"tags":[],"_links":{"self":[{"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/posts\/984"}],"collection":[{"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/comments?post=984"}],"version-history":[{"count":4,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/posts\/984\/revisions"}],"predecessor-version":[{"id":1869,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/posts\/984\/revisions\/1869"}],"wp:attachment":[{"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/media?parent=984"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/categories?post=984"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chat-messenger.com\/vi\/wp-json\/wp\/v2\/tags?post=984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}