<commit_before>package eu.scasefp7.eclipse.core.connect.uploader;

import java.io.File;
import java.io.FileNotFoundException;
import java.nio.charset.Charset;
import java.util.Scanner;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;

import eu.scasefp7.eclipse.core.connect.Activator;

public class StringFileHelpers {

	public static String readFileToString(File file) {
		String text = "";
		try {
			Scanner scanner = new Scanner(file);
			text = scanner.useDelimiter("\\A").next();
			scanner.close();
		} catch (FileNotFoundException e) {
			Activator.log("Error reading file " + file.getName(), e);
		}
		return text;
	}

	public static String readFileToString(IFile file) {
		String text = "";
		try {
			Scanner scanner = new Scanner(file.getContents());
			text = scanner.useDelimiter("\\A").next();
			scanner.close();
		} catch (CoreException e) {
			Activator.log("Error reading file " + file.getName(), e);
		}
		return text;
	}

	public static String convertStringToBytes(String text) {
		String byteArray = "";
		byte[] bytes = text.getBytes(Charset.forName("UTF-8"));
		for (byte b : bytes) {
			byteArray += b;
			byteArray += ",";
		}
		byteArray = byteArray.length() > 0 ? byteArray.substring(0, byteArray.length() - 1) : "";
		return byteArray;
	}

}<commit_msg>Optimize conversion of string to bytes<commit_after>package eu.scasefp7.eclipse.core.connect.uploader;

import java.io.File;
import java.io.FileNotFoundException;
import java.nio.charset.Charset;
import java.util.Scanner;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;

import eu.scasefp7.eclipse.core.connect.Activator;

public class StringFileHelpers {

	public static String readFileToString(File file) {
		String text = "";
		try {
			Scanner scanner = new Scanner(file);
			text = scanner.useDelimiter("\\A").next();
			scanner.close();
		} catch (FileNotFoundException e) {
			Activator.log("Error reading file " + file.getName(), e);
		}
		return text;
	}

	public static String readFileToString(IFile file) {
		String text = "";
		try {
			Scanner scanner = new Scanner(file.getContents());
			text = scanner.useDelimiter("\\A").next();
			scanner.close();
		} catch (CoreException e) {
			Activator.log("Error reading file " + file.getName(), e);
		}
		return text;
	}

	public static String convertStringToBytes(String text) {
		StringBuilder byteArrayBuilder = new StringBuilder();
		byte[] bytes = text.getBytes(Charset.forName("UTF-8"));
		String delim = "";
		for (byte b : bytes) {
			byteArrayBuilder.append(delim);
			delim = ",";
			byteArrayBuilder.append(b);
		}
		return byteArrayBuilder.toString();
	}

}
{'fraction_non_alphanumeric': 0.13786696395392048, 'fraction_numerical': 0.0033444816053511705, 'mean_word_length': 4.157088122605364, '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': '145882', 'n_tokens_mistral': 950, 'n_tokens_neox': 858, 'n_words': 191}