<commit_before>package com.xoba.mra;

import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Toolkit;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Random;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.UUID;
import java.util.Map.Entry;

public class MraUtils {

    private static final ILogger logger = LogFactory.getDefault().create();

    private MraUtils() {
    }

    public static final String US_ASCII = "US-ASCII";

    public static Dimension getMaxWindowDimension(double fraction) {
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] gs = ge.getScreenDevices();
        int height = new Double(fraction * gs[0].getDisplayMode().getHeight()).intValue();
        int width = new Double(fraction * gs[0].getDisplayMode().getWidth()).intValue();
        return new Dimension(width, height);
    }

    public static String getRandomMD5Hash(int bytesOfRandomness) {
        byte[] buf = new byte[bytesOfRandomness];
        new Random().nextBytes(buf);
        return md5Hash(buf);
    }

    public static String md5Hash(String buf) {
        try {
            return md5Hash(buf.getBytes(US_ASCII));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }

    public static byte[] md5HashStringToBytes(String buf) {
        try {
            return md5HashBytesToBytes(buf.getBytes(US_ASCII));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
<commit_msg>load from inputstream to bytes<commit_after>package com.xoba.mra;

import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Toolkit;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Random;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.UUID;
import java.util.Map.Entry;

public class MraUtils {

    private static final ILogger logger = LogFactory.getDefault().create();

    private MraUtils() {
    }

    public static final String US_ASCII = "US-ASCII";

    public static Dimension getMaxWindowDimension(double fraction) {
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] gs = ge.getScreenDevices();
        int height = new Double(fraction * gs[0].getDisplayMode().getHeight()).intValue();
        int width = new Double(fraction * gs[0].getDisplayMode().getWidth()).intValue();
        return new Dimension(width, height);
    }

    public static byte[] load(InputStream in) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        copy(in, out);
        out.close();
        return out.toByteArray();
    }

    public static String getRandomMD5Hash(int bytesOfRandomness) {
        byte[] buf = new byte[bytesOfRandomness];
        new Random().nextBytes(buf);
        return md5Hash(buf);
    }

    public static String md5Hash(String buf) {
        try {
            return md5Hash(buf.getBytes(US_ASCII));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }

    public static byte[] md5HashStringToBytes(String buf) {
        try {
            return md5HashBytesToBytes(buf.getBytes(US_ASCII));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }

{'fraction_non_alphanumeric': 0.10040907400520639, 'fraction_numerical': 0.0029750836742283376, 'mean_word_length': 3.9393939393939394, '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': '6863337', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1541, 'n_words': 354}