{"id":656,"date":"2013-11-18T06:08:29","date_gmt":"2013-11-18T06:08:29","guid":{"rendered":"http:\/\/shivdev.com\/blog\/?p=656"},"modified":"2013-11-18T06:13:03","modified_gmt":"2013-11-18T06:13:03","slug":"read-a-file-into-a-string-using-a-single-statement","status":"publish","type":"post","link":"http:\/\/shivdev.com\/blog\/2013\/11\/18\/read-a-file-into-a-string-using-a-single-statement\/","title":{"rendered":"Read a File into a String using a single statement"},"content":{"rendered":"<p>I&#8217;ve found that <a href=\"http:\/\/docs.oracle.com\/javase\/1.5.0\/docs\/api\/java\/util\/Scanner.html\">java.util.Scanner<\/a> class instead of the java.io classes to work well for most of my text file reading and parsing needs. <\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nString content = new Scanner(new File(&quot;\/path\/to\/file.txt&quot;)).useDelimiter(&quot;\\\\Z&quot;).next();\r\nSystem.out.println(content);\r\n<\/pre>\n<p>For more info read up <a href=\"http:\/\/natch3z.blogspot.com\/2008\/11\/read-text-file-using-javautilscanner.html\">natch3z<\/a> or <a href=\"https:\/\/coderwall.com\/p\/lyalwg\">coderwall<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve found that java.util.Scanner class instead of the java.io classes to work well for most of my text file reading and parsing needs. For more info read up natch3z or coderwall.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/656"}],"collection":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/comments?post=656"}],"version-history":[{"count":4,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/656\/revisions"}],"predecessor-version":[{"id":660,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/656\/revisions\/660"}],"wp:attachment":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/media?parent=656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/categories?post=656"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/tags?post=656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}