<commit_before>package uk.ac.cam.cl.echo.extrusionfinder.server.sourcer.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.ConnectException;
 
/**
 * Utility class for various file system related methods.
 */
public class FileUtility {

    private static final int BUFFER_SIZE = 16384;

    private FileUtility() {}
 
    /**
     * Downloads a file from a URL
     * @param fileURL HTTP URL of the file to be downloaded
     * @param saveDir path of the directory to save the file
     * @return  Path to saved file
     * @throws IOException if writing to file system failed
     * @throws FileUtilityException if the http url connection failed
     * slightly modified from:
     * http://www.codejava.net/java-se/networking/use-httpurlconnection-to-download-file-from-an-http-url
     */
    public static String downloadFile(String fileURL, String saveDir)
        throws IOException, ConnectException {

        fileURL = fileURL.replace(" ", "%20");

        URL url = new URL(fileURL);
        HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
        int responseCode = httpConn.getResponseCode();
 
        // always check HTTP response code first
        if (responseCode == HttpURLConnection.HTTP_OK) {
            String disposition = httpConn.getHeaderField("Content-Disposition");<commit_msg>And now it compiles as well<commit_after>package uk.ac.cam.cl.echo.extrusionfinder.server.sourcer.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.ConnectException;
 
/**
 * Utility class for various file system related methods.
 */
public class FileUtility {

    private static final int BUFFER_SIZE = 16384;

    private FileUtility() {}
 
    /**
     * Downloads a file from a URL
     * @param fileURL HTTP URL of the file to be downloaded
     * @param saveDir path of the directory to save the file
     * @return  Path to saved file
     * @throws IOException if writing to file system failed
     * @throws ConnectException if the http url connection failed
     * slightly modified from:
     * http://www.codejava.net/java-se/networking/use-httpurlconnection-to-download-file-from-an-http-url
     */
    public static String downloadFile(String fileURL, String saveDir)
        throws IOException, ConnectException {

        fileURL = fileURL.replace(" ", "%20");

        URL url = new URL(fileURL);
        HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
        int responseCode = httpConn.getResponseCode();
 
        // always check HTTP response code first
        if (responseCode == HttpURLConnection.HTTP_OK) {
            String disposition = httpConn.getHeaderField("Content-Disposition");
{'fraction_non_alphanumeric': 0.08899456521739131, 'fraction_numerical': 0.004755434782608696, 'mean_word_length': 3.2805232558139537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6821122', 'n_tokens_mistral': 808, 'n_tokens_neox': 780, 'n_words': 248}