Add ResourceGetter util
This commit is contained in:
parent
7c4bad6ab0
commit
13879d2c9a
1 changed files with 14 additions and 0 deletions
|
@ -0,0 +1,14 @@
|
||||||
|
package group.ouroboros.potrogue.util
|
||||||
|
|
||||||
|
import java.net.URL
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Paths
|
||||||
|
|
||||||
|
class ResourceGetter {
|
||||||
|
fun downloadFile(url: URL, fileName: String) {
|
||||||
|
url.openStream().use { Files.copy(it, Paths.get(fileName)) }
|
||||||
|
}
|
||||||
|
|
||||||
|
//EXAMPLE USAGE
|
||||||
|
// ResourceGetter().downloadFile(URL("https://url.to/resource.txt"), "location/to/store/resource.txt")
|
||||||
|
}
|
Loading…
Reference in a new issue