Here you can find the source of fixture(String filename, Charset charset)
Parameter | Description |
---|---|
filename | the filename of the fixture file |
charset | the character set of filename |
Parameter | Description |
---|---|
IllegalArgumentException | if an I/O error occurs. |
private static String fixture(String filename, Charset charset)
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import com.google.common.io.Resources; public class Main { /**/*from w w w .ja v a 2 s . co m*/ * Reads fixture file from classpath, e.g {@code src/test/resources} * and returns its content as UTF-8 string. * * @param filename the filename of the fixture file * @return content of file as UTF-8 string * @throws IllegalArgumentException if an I/O error occurs. */ public static String fixture(String filename) { return fixture(filename, StandardCharsets.UTF_8); } /** * Reads fixture file from classpath, e.g {@code src/test/resources} * and returns its content as string. * * @param filename the filename of the fixture file * @param charset the character set of {@code filename} * @return content of file as string * @throws IllegalArgumentException if an I/O error occurs. */ private static String fixture(String filename, Charset charset) { try { return Resources.toString(Resources.getResource(filename), charset); } catch (IOException ex) { throw new IllegalArgumentException(ex); } } }