Skip to content

Instantly share code, notes, and snippets.

@amr
Created October 2, 2014 10:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amr/cc51a04d3511d272db36 to your computer and use it in GitHub Desktop.
Save amr/cc51a04d3511d272db36 to your computer and use it in GitHub Desktop.
Create temporary directory with the JVM (Scala here)
def createTempDir(tmpName: String): String = {
val tmpDir = Paths.get(System.getProperty("java.io.tmpdir"))
val name: Path = tmpDir.getFileSystem.getPath(tmpName)
if (name.getParent != null) throw new IllegalArgumentException("Invalid prefix or suffix")
tmpDir.resolve(name).toString
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment