Compdigitec Labs

« | Home | »

Getting files from sources in Scala

By admin | February 14, 2021

// Java-based ways
getClass.getResource("/html/myfile.html")
println(Source.fromInputStream(getClass.getResourceAsStream("/html/myfile.html")).mkString)

// Scala-native way
// Note: NO LEADING SLASH
println(Source.fromResource("html/myfile.html").getLines.toList)

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: Code | 28 Comments »

28 Responses to “Getting files from sources in Scala”

  1. trauma therapy san diego Says:
    March 14th, 2022 at 19:24

    … [Trackback]

    […] Read More on that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/ […]

  2. สล็อตวอเลท ไม่มีขั้นต่ำ Says:
    April 9th, 2022 at 04:01

    … [Trackback]

    […] Find More Info here to that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/ […]

  3. fake watches Says:
    April 20th, 2022 at 14:52

    … [Trackback]

    […] Info to that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/ […]

  4. sbo Says:
    May 7th, 2022 at 18:27

    … [Trackback]

    […] There you can find 94979 more Info on that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/ […]

  5. dumps shop online Says:
    June 7th, 2022 at 12:23

    … [Trackback]

    […] Read More Information here to that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/ […]

  6. Godwins Says:
    June 13th, 2022 at 15:56

    am good

  7. Godwins Says:
    June 13th, 2022 at 16:02

    am cool like that

  8. Godwins Says:
    June 13th, 2022 at 18:33

    ok for me

  9. richmond Says:
    June 13th, 2022 at 18:40

    we pay well

  10. cblack Says:
    June 13th, 2022 at 18:46

    what a tough one

  11. cblack Says:
    June 13th, 2022 at 18:51

    what a joke

  12. 홀덤 Says:
    June 15th, 2022 at 18:33

    … [Trackback]

    […] Find More on that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/ […]

  13. eminent Says:
    June 22nd, 2022 at 17:24

    More on that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/ […]

  14. eminent Says:
    June 22nd, 2022 at 17:28

    on that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/

  15. eminent Says:
    June 22nd, 2022 at 17:30

    that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/

  16. eminent Says:
    June 22nd, 2022 at 17:31

    once happy

  17. eminent Says:
    June 22nd, 2022 at 17:32

    always happy

  18. eminent Says:
    June 22nd, 2022 at 17:33

    blogroll

  19. eminent Says:
    June 22nd, 2022 at 17:33

    germany

  20. eminent Says:
    June 22nd, 2022 at 17:38

    capital

  21. eminent Says:
    June 22nd, 2022 at 17:38

    poland

  22. eminent Says:
    June 22nd, 2022 at 17:39

    required

  23. eminent Says:
    June 22nd, 2022 at 17:40

    america

  24. eminent Says:
    June 22nd, 2022 at 17:43

    mathematic

  25. pg slot เครดิตฟรี 100 Says:
    June 23rd, 2022 at 11:06

    Pg Slot เครดิตฟรี 100 สมัครง่าย ผ่านระบบออโต้สมัครง่าย ผ่านระบบออโต้อัตโนมัติ สล็อต มีทีมงานคุณภาพ ที่ท่านสามารถไว้วางใจได้ สมัครง่าย ปลอดภัย 100 % มันคงไว้ใจได้กับเว็บสล็อตออนไลน์

  26. TVS Jardin Says:
    June 24th, 2022 at 10:11

    … [Trackback]

    […] Find More to that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/ […]

  27. maxbet Says:
    June 25th, 2022 at 18:37

    … [Trackback]

    […] Find More to that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/ […]

  28. De quelle manière introduire La demande de prêt ? - Mon créditComment introduire la demande de prêt ? - Mon crédit Says:
    June 26th, 2022 at 07:34

    … [Trackback]

    […] Info on that Topic: compdigitec.com/labs/2021/02/14/getting-files-from-sources-in-scala/ […]

Comments