{"id":930,"date":"2018-09-17T18:32:08","date_gmt":"2018-09-17T09:32:08","guid":{"rendered":"https:\/\/chat-messenger.com\/?p=930"},"modified":"2018-12-23T02:00:32","modified_gmt":"2018-12-22T17:00:32","slug":"file-getsuffix","status":"publish","type":"post","link":"https:\/\/chat-messenger.com\/en\/blog\/java\/file-getsuffix","title":{"rendered":"Get extension from Java filename"},"content":{"rendered":"<h2 class=\"common_title\"><a name=\"0\">Java <strong>file-name<\/strong>, ,<strong>file path<\/strong>from (e.g. time, place, numerical quantity)<strong>(filename) extension<\/strong>Retrieve the<\/a><\/h2>\n<p>\nJava.<strong>file-name<\/strong>from (e.g. time, place, numerical quantity)<strong>(filename) extension<\/strong>The following is a sample source to obtain\n<\/p>\n<h2 class=\"common_title\"><a name=\"1\">sample program<\/a><\/h2>\n<pre class=\"sample_src\">\/**\r\n * @param fileName returns the file extension from the filename.\r\n * @param fileName file name\r\n * @return file extension\r\n *\/\r\npublic static String getSuffix(String fileName) {\r\n    if (fileName == null)\r\n        return null;\r\n    int point = fileName.lastIndexOf(\".\") ;\r\n    if (point ! = -1) {\r\n        return fileName.substring(point + 1); }\r\n    }\r\n    return fileName; }\r\n}\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\">Execution Result<\/a><\/h2>\n<p>\u25c6Example of Execution<\/p>\n<pre class=\"sample_src\">\/**\r\n * Execution example\r\n * @param args\r\n *\/\r\npublic static void main(String[] args) {\r\n    String ret1 = getSuffix(\"test.html\");\r\n    System.out.println(ret1);\r\n    String ret2 = getSuffix(\"C:\\\\test.html\");\r\n    System.out.println(ret2);\r\n}\r\n<\/pre>\n<p>\u25c6Output result<\/p>\n<pre class=\"console\">html\r\nhtml\r\n\r\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>Get extension from Java file name and file path This is a sample source for getting extension from file name in Java [\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\/en\/wp-json\/wp\/v2\/posts\/930"}],"collection":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/comments?post=930"}],"version-history":[{"count":4,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/930\/revisions"}],"predecessor-version":[{"id":1889,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/930\/revisions\/1889"}],"wp:attachment":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/media?parent=930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/categories?post=930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/tags?post=930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}