title: How to read files from resources folder in Scala?
body: <p>I have a folder structure like below:</p>
  
  <pre><code>- main
  -- java
  -- resources 
  -- scalaresources
  --- commandFiles 
  </code></pre>
  
  <p>and in that folders I have my files that I have to read.
  Here is the code:</p>
  
  <pre><code>def readData(runtype: String, snmphost: String, comstring: String, specificType:  String): Unit = {
    val realOrInvFile = "/commandFiles/snmpcmds." +runtype.trim // these files are under commandFiles folder, which I have to read. 
      try {
        if (specificType.equalsIgnoreCase("Cisco")) {
          val specificDeviceFile: String = "/commandFiles/snmpcmds."+runtype.trim+ ".cisco"
          val realOrInvCmdsList = scala.io.Source.fromFile(realOrInvFile).getLines().toList.filterNot(line =&gt; line.startsWith("#")).map{
            //some code 
          }
          val specificCmdsList = scala.io.Source.fromFile(specificDeviceFile).getLines().toList.filterNot(line =&gt; line.startsWith("#")).map{
            //some code
          }
        }
      } catch {
        case e: Exception =&gt; e.printStackTrace
      }
    }
  }
  </code></pre>