<commit_before>/*
 * Copyright 2016 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.mkjensen.dml;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Helper methods for loading test resources.
 */
public final class ResourceUtils {

  private ResourceUtils() {
  }

  /**
   * Loads a resource and converts it to a string.
   *
   * @param resName path to the resource to load, relative to {@code src/test/resources}
   */
  public static String loadAsString(String resName) {
    try (InputStream stream = ResourceUtils.class.getClassLoader().getResourceAsStream(resName)) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
      StringBuilder result = new StringBuilder(stream.available());
      String line;
      while ((line = reader.readLine()) != null) {
        result.append(line);
      }
      return result.toString();
    } catch (IOException ex) {
      throw new RuntimeException(ex);
    }
  }
}<commit_msg>Avoid warning about throwing raw exception types<commit_after>/*
 * Copyright 2016 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.mkjensen.dml;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Helper methods for loading test resources.
 */
public final class ResourceUtils {

  private ResourceUtils() {
  }

  /**
   * Loads a resource and converts it to a string.
   *
   * @param resName path to the resource to load, relative to {@code src/test/resources}
   */
  public static String loadAsString(String resName) {
    try (InputStream stream = ResourceUtils.class.getClassLoader().getResourceAsStream(resName)) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
      StringBuilder result = new StringBuilder(stream.available());
      String line;
      while ((line = reader.readLine()) != null) {
        result.append(line);
      }
      return result.toString();
    } catch (IOException ex) {
      throw new DmlException(ex);
    }
  }
}
{'fraction_non_alphanumeric': 0.09305249921408362, 'fraction_numerical': 0.005029864822382898, 'mean_word_length': 3.5652797704447634, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1691433', 'n_tokens_mistral': 847, 'n_tokens_neox': 833, 'n_words': 322}