{"id":924,"date":"2018-09-17T18:27:12","date_gmt":"2018-09-17T09:27:12","guid":{"rendered":"https:\/\/chat-messenger.com\/?p=924"},"modified":"2018-12-23T02:00:53","modified_gmt":"2018-12-22T17:00:53","slug":"file-getpreffix","status":"publish","type":"post","link":"https:\/\/chat-messenger.com\/en\/blog\/java\/file-getpreffix","title":{"rendered":"Remove extensions from Java filenames"},"content":{"rendered":"<h2 class=\"common_title\"><a name=\"0\">Remove extensions from Java filenames<\/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 that returns the name without the\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 filename without the file extension.\r\n * @param fileName filename\r\n * @return fileName\r\n *\/\r\npublic static String getPreffix(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(0, point); }\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 = getPreffix(\"test.html\");\r\n    System.out.println(ret1);\r\n    String ret2 = getPreffix(\"C:\\\\test.html\");\r\n    System.out.println(ret2); }\r\n}\r\n<\/pre>\n<p>\u25c6Output result<\/p>\n<pre class=\"console\">test\r\nC:\\test\r\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>Java Remove extension from file name Sample source that returns file name with extension removed 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\/924"}],"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=924"}],"version-history":[{"count":4,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/924\/revisions"}],"predecessor-version":[{"id":1891,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/924\/revisions\/1891"}],"wp:attachment":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/media?parent=924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/categories?post=924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/tags?post=924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}