From 13879d2c9abf36227fa29766251a30bea5be51f8 Mon Sep 17 00:00:00 2001 From: LimePotato Date: Mon, 6 Nov 2023 02:59:10 -0700 Subject: [PATCH] Add ResourceGetter util --- .../ouroboros/potrogue/util/ResourceGetter.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/kotlin/group/ouroboros/potrogue/util/ResourceGetter.kt diff --git a/src/main/kotlin/group/ouroboros/potrogue/util/ResourceGetter.kt b/src/main/kotlin/group/ouroboros/potrogue/util/ResourceGetter.kt new file mode 100644 index 0000000..a0b9313 --- /dev/null +++ b/src/main/kotlin/group/ouroboros/potrogue/util/ResourceGetter.kt @@ -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") +} \ No newline at end of file