{"id":422,"date":"2021-02-14T15:56:31","date_gmt":"2021-02-14T20:56:31","guid":{"rendered":"http:\/\/www.compdigitec.com\/labs\/?p=422"},"modified":"2021-02-14T15:56:31","modified_gmt":"2021-02-14T20:56:31","slug":"getting-files-from-sources-in-scala","status":"publish","type":"post","link":"http:\/\/www.compdigitec.com\/labs\/2021\/02\/14\/getting-files-from-sources-in-scala\/","title":{"rendered":"Getting files from sources in Scala"},"content":{"rendered":"<pre class=\"wp-block-preformatted\">\/\/ Java-based ways\ngetClass.getResource(\"\/html\/myfile.html\")\nprintln(Source.fromInputStream(getClass.getResourceAsStream(\"\/html\/myfile.html\")).mkString)\n\n\/\/ Scala-native way\n\/\/ Note: NO LEADING SLASH\nprintln(Source.fromResource(\"html\/myfile.html\").getLines.toList)\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>\/\/ Java-based ways getClass.getResource(&#8220;\/html\/myfile.html&#8221;) println(Source.fromInputStream(getClass.getResourceAsStream(&#8220;\/html\/myfile.html&#8221;)).mkString) \/\/ Scala-native way \/\/ Note: NO LEADING SLASH println(Source.fromResource(&#8220;html\/myfile.html&#8221;).getLines.toList)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[900],"tags":[904,903,901],"_links":{"self":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/422"}],"collection":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/comments?post=422"}],"version-history":[{"count":0,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/422\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/media?parent=422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/categories?post=422"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/tags?post=422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}