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 | 243 Comments »

243 Responses to “Getting files from sources in Scala”

  1. dany Says:
    February 13th, 2023 at 20:57

    minus

  2. dany Says:
    February 13th, 2023 at 21:04

    https://rondastore.shop/

  3. dany Says:
    February 13th, 2023 at 21:14

    new

  4. y2 mate Says:
    February 14th, 2023 at 05:36

    … [Trackback]

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

  5. dany Says:
    February 18th, 2023 at 11:29

    steping up

  6. dany Says:
    February 18th, 2023 at 11:36

    extremly good

  7. dany Says:
    February 18th, 2023 at 14:50

    over legit

  8. dany Says:
    February 18th, 2023 at 14:52

    massive gain

  9. dany Says:
    February 18th, 2023 at 15:02

    active

  10. dany Says:
    March 1st, 2023 at 15:58

    decide

  11. youtube video downloader free download Says:
    March 1st, 2023 at 19:39

    … [Trackback]

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

  12. mm88 Says:
    March 4th, 2023 at 00:21

    … [Trackback]

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

  13. eminent Says:
    March 4th, 2023 at 22:06

    Visionary

  14. eminent Says:
    March 4th, 2023 at 22:06

    Vivacious

  15. eminent Says:
    March 4th, 2023 at 22:07

    positive words

  16. eminent Says:
    March 4th, 2023 at 22:08

    Warm – kind

  17. eminent Says:
    March 4th, 2023 at 22:10

    Well-read

  18. eminent Says:
    March 4th, 2023 at 22:12

    Whimsical

  19. dany Says:
    March 5th, 2023 at 01:25

    grace

  20. dany Says:
    March 5th, 2023 at 01:36

    peace

  21. dany Says:
    March 5th, 2023 at 01:43

    united

  22. พนันบอลออนไลน์ Says:
    March 8th, 2023 at 18:56

    … [Trackback]

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

  23. dany Says:
    March 19th, 2023 at 14:34

    glowing

  24. dany Says:
    March 19th, 2023 at 15:01

    quicky

  25. dany Says:
    March 19th, 2023 at 15:13

    sweety

  26. dany Says:
    March 19th, 2023 at 15:21

    desired

  27. dany Says:
    March 19th, 2023 at 15:26

    captain

  28. dany Says:
    March 19th, 2023 at 15:48

    savana

  29. dany Says:
    March 19th, 2023 at 15:57

    basic

  30. dany Says:
    March 19th, 2023 at 16:02

    economy

  31. dany Says:
    March 22nd, 2023 at 12:40

    werey

  32. dany Says:
    March 22nd, 2023 at 13:09

    getat

  33. buy glock 26 Says:
    March 26th, 2023 at 05:24

    … [Trackback]

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

  34. dany Says:
    March 26th, 2023 at 08:34

    aiiiiiiiii

  35. dany Says:
    March 26th, 2023 at 08:41

    biiiiii

  36. dany Says:
    March 26th, 2023 at 08:48

    ciiiiii

  37. dany Says:
    March 26th, 2023 at 08:50

    diiiiii

  38. dany Says:
    March 26th, 2023 at 08:53

    eiiiiii

  39. dany Says:
    March 26th, 2023 at 08:55

    fiiiiii

  40. dany Says:
    March 26th, 2023 at 08:57

    giiiiii

  41. dany Says:
    March 26th, 2023 at 08:59

    hiiiiii

  42. dany Says:
    March 26th, 2023 at 09:01

    jiiiiii

  43. dany Says:
    March 26th, 2023 at 09:11

    kiiiiii

Comments