{"id":19,"date":"2009-10-28T17:27:19","date_gmt":"2009-10-28T16:27:19","guid":{"rendered":"http:\/\/www.flamingpenguin.co.uk\/blog\/?p=19"},"modified":"2010-01-05T15:58:51","modified_gmt":"2010-01-05T14:58:51","slug":"apache-vfs-uri-with-spaces","status":"publish","type":"post","link":"https:\/\/www.flamingpenguin.co.uk\/blog\/2009\/10\/28\/apache-vfs-uri-with-spaces\/","title":{"rendered":"Apache VFS URI with spaces"},"content":{"rendered":"<p>Apache VFS currently seems to have a <a href=\"https:\/\/issues.apache.org\/jira\/browse\/VFS-203?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&#038;focusedCommentId=12675797#action_12675797\">problem<\/a> handling file paths with spaces in them if you want to convert that path to a URI.<\/p>\n<p>Here is a workaround that will at least handle that case (if not every case of wrongly encoded data):<\/p>\n<pre lang=\"java\">\r\n\/**\r\n * Convert a file object to a URI\r\n *\r\n * There is a bug in the way that apache VFS handles paths with spaces in\r\n * https:\/\/issues.apache.org\/jira\/browse\/VFS-203?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12675797#action_12675797\r\n *\r\n * @param resource the resource to convert\r\n *\r\n * @return a valid URI for the file object\r\n *\r\n * @throws URISyntaxException\r\n *\/\r\npublic URI fileObjectToUri(final FileObject resource) throws URISyntaxException\r\n{\r\n   return new URI(resource.getName().getURI().replace(\" \", \"%20\"));\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Apache VFS currently seems to have a problem handling file paths with spaces in them if you want to convert that path to a URI. Here is a workaround that will at least handle that case (if not every case &hellip; <a href=\"https:\/\/www.flamingpenguin.co.uk\/blog\/2009\/10\/28\/apache-vfs-uri-with-spaces\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":0,"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.flamingpenguin.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}