title: How to write a file to "target" directory of Scala SBT project?
body: <p>I want to create folder and write files in the <strong><em>\target\</em></strong> sub directory of my project, but the only thing I have been able to accomplish is providing a string of the file name and the file will be created in <strong><em>\.idea\modules\</em></strong>.</p>
  
  <p>There is not enough info on this at all. Everybody only talks about accessing the \resources\ directory.</p>
  
  <p>Can anybody help me out?</p>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE</strong>: I managed to hack a way to accomplish making a folder under the "target" directory. It may look ugly, I wonder if this is the only way.</p>
  
  <pre><code>import java.io.File
  import java.nio.file.{Files, Path, Paths}
  
  val targetDir: Path = Paths.get(getClass.getClassLoader.getResource("").toURI).getParent.getParent
  val newFolderString = targetDir.toString() + "/myNewFolder"
  
  val directory: File = new File(newFolderString)
  directory.mkdir()
  </code></pre>