package net.jselby.escapists.utils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

/**
 * Basic IOUtils replacement.
 */
public class IOUtils {
    public static byte[] toByteArray(URL url) throws IOException {
        InputStream in = url.openStream();
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        byte[] buf = new byte[1024];
        int val;
        while((val = in.read(buf)) != -1) {
            out.write(buf, 0, val);
        }

        in.close();

        return out.toByteArray();
    }

    public static String toString(URL url) throws IOException {
        return new String(toByteArray(url));
    }
}

@@ -49,85 +49,9 @@
 .io.
-ByteArrayOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream
+*
 ;%0Aim
@@ -131,16 +131,66 @@
 Utils %7B%0A
+    private final static int BUFFER_SIZE = 8192;%0A%0A
     publ
@@ -391,12 +391,420 @@
 yte%5B
-1024
+BUFFER_SIZE%5D;%0A        int val;%0A        while((val = in.read(buf)) != -1) %7B%0A            out.write(buf, 0, val);%0A        %7D%0A%0A        in.close();%0A%0A        return out.toByteArray();%0A    %7D%0A%0A    public static byte%5B%5D toByteArray(File file) throws IOException %7B%0A        InputStream in = new FileInputStream(file);%0A        ByteArrayOutputStream out = new ByteArrayOutputStream();%0A%0A        byte%5B%5D buf = new byte%5BBUFFER_SIZE
 %5D;%0A 

Add better caching to IOUtils