<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.nativelibs4java.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

/**
 *
 * @author Olivier
 */
public class IOUtils {
    public static String readText(File f) throws IOException {
        Reader in = new FileReader(f);
        try {
            return readText(in);
        } finally {
            in.close();
        }
    }
    public static String readText(InputStream in) throws IOException {
        return readText(new InputStreamReader(in));
    }
    public static String readTextClose(InputStream in) throws IOException {
        return readTextClose(new InputStreamReader(in));
    }
    public static String readTextClose(Reader in) throws IOException {
        try {
            return readText(in);
        } finally {
            in.close();
        }
    }
    public static String readText(Reader in) throws IOException {
        StringBuffer b = new StringBuffer();
        BufferedReader bin = new BufferedReader(in);
        String line;
        while ((line = bin.readLine()) != null) {
            b.append(line);
            b.append('\n');
        }
        return b.toString();
    }
}<commit_msg>NL4J Common : added IOUtils.readWrite, .readText(URL)<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.nativelibs4java.util;

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

/**
 *
 * @author Olivier
 */
public class IOUtils {
    public static String readText(File f) throws IOException {
        Reader in = new FileReader(f);
        try {
            return readText(in);
        } finally {
            in.close();
        }
    }
    public static String readText(InputStream in) throws IOException {
        return readText(new InputStreamReader(in));
    }
    public static String readText(URL url) throws IOException {
        return readTextClose(url.openStream());
    }
    public static String readTextClose(InputStream in) throws IOException {
        return readTextClose(new InputStreamReader(in));
    }
    public static String readTextClose(Reader in) throws IOException {
        try {
            return readText(in);
        } finally {
            in.close();
        }
    }
    public static String readText(Reader in) throws IOException {
        StringBuffer b = new StringBuffer();
        BufferedReader bin = new BufferedReader(in);
        String line;
        while ((line = bin.readLine()) != null) {
            b.append(line);
            b.append('\n');
        }
        return b.toString();
    }
    public static void readWrite(InputStream in, OutputStream out) throws IOException {
    		byte[] buf = new byte[1024];
    		int len;
    		while ((len = in.read(buf)) > 0)
    			out.write(buf, 0, len);
    }
}
{'fraction_non_alphanumeric': 0.10135806558463067, 'fraction_numerical': 0.0029811195760185492, 'mean_word_length': 2.3481152993348116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3405292', 'n_tokens_mistral': 835, 'n_tokens_neox': 830, 'n_words': 243}