Last active
January 9, 2023 17:45
-
-
Save hhimanshu/6b1a2b7bf49f50ac602ce5928b74b2bd to your computer and use it in GitHub Desktop.
Copy File inside Jar to External Location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File | |
import java.net.URL | |
// Note: This has dependency on apache commons-io | |
import org.apache.commons.io.FileUtils | |
object LoadFile extends App { | |
override def main(args: Array[String]): Unit = { | |
val fileName = "myfileJarFile.json" | |
val path: URL = getClass.getClassLoader.getResource("v410.all/" + fileName) | |
val destination = new File("/Users/harit/Downloads/" + fileName) | |
FileUtils.copyURLToFile(path, destination) | |
println(s"copied $path to $destination") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
scala -classpath target/scala-2.11/my.jar LoadFile