From a0ff501947a84b268e099524a06b56a6b900dad2 Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Tue, 3 May 2022 18:25:32 +0200 Subject: move to cc.polyfrost --- .../java/io/polyfrost/oneconfig/lwjgl/IOUtil.java | 56 ---------------------- 1 file changed, 56 deletions(-) delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java (limited to 'src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java') diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java deleted file mode 100644 index 63026e6..0000000 --- a/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.polyfrost.oneconfig.lwjgl; - -import org.apache.commons.io.IOUtils; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.file.Files; - -public final class IOUtil { - - private IOUtil() { - } - - /** - * Taken from legui under MIT License - * https://github.com/SpinyOwl/legui/blob/develop/LICENSE - */ - public static ByteBuffer resourceToByteBuffer(String path) throws IOException { - byte[] bytes; - path = path.trim(); - if (path.startsWith("http")) { - bytes = IOUtils.toByteArray(new URL(path)); - } else { - InputStream stream; - File file = new File(path); - if (file.exists() && file.isFile()) { - stream = Files.newInputStream(file.toPath()); - } else { - stream = IOUtil.class.getResourceAsStream(path); - } - if (stream == null) { - throw new FileNotFoundException(path); - } - bytes = IOUtils.toByteArray(stream); - } - ByteBuffer data = ByteBuffer.allocateDirect(bytes.length).order(ByteOrder.nativeOrder()) - .put(bytes); - ((Buffer) data).flip(); - return data; - } - - public static ByteBuffer resourceToByteBufferNullable(String path) { - try { - return resourceToByteBuffer(path); - } catch (Exception ignored) { - return null; - } - } - -} \ No newline at end of file -- cgit