<commit_before>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));
    }
}
<commit_msg>Add better caching to IOUtils<commit_after>package net.jselby.escapists.utils;

import java.io.*;
import java.net.URL;

/**
 * Basic IOUtils replacement.
 */
public class IOUtils {
    private final static int BUFFER_SIZE = 8192;

    public static byte[] toByteArray(URL url) throws IOException {
        InputStream in = url.openStream();
        ByteArrayOutputStream out = new ByteArrayOutputStream();

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

        in.close();

        return out.toByteArray();
    }

    public static byte[] toByteArray(File file) throws IOException {
        InputStream in = new FileInputStream(file);
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        byte[] buf = new byte[BUFFER_SIZE];
        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));
    }
}

{'fraction_non_alphanumeric': 0.11542553191489362, 'fraction_numerical': 0.007446808510638298, 'mean_word_length': 2.489795918367347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4039116', 'n_tokens_mistral': 553, 'n_tokens_neox': 536, 'n_words': 146}