/** * Reads a {@link File} and returns a {@String}. */ public static String toString(File file, Charset charset) throws IOException { byte[] bytes = readBytes(file); if (charset != null) { return new String(bytes, charset); } else { return new String(bytes); } }
/** * Reads an {@link InputStream} and returns a {@String}. */ public static String toString(InputStream inputStream, Charset charset) throws IOException { byte[] bytes = readBytes(inputStream); if (charset != null) { return new String(bytes, charset); } else { return new String(bytes); } }
/** * Loads the YAML file for the given DTO class */ public static <T> T loadYaml(InputStream in, Class<T> clazz) throws IOException { byte[] data = Files.readBytes(in); return loadYaml(data, clazz); }
/** * Loads the YAML file for the given DTO class */ public static <T> T loadYaml(InputStream in, Class<T> clazz) throws IOException { byte[] data = Files.readBytes(in); return loadYaml(data, clazz); }
protected Response doRawFile(String path) throws IOException { final File file = getRelativeFile(path); if (LOG.isDebugEnabled()) { LOG.debug("reading file: " + file.getPath()); } if (file.isDirectory()) { // TODO return a listing? Object directoryDto = null; return Response.ok(directoryDto).build(); } else { byte[] data = Files.readBytes(file); return Response.ok(data).build(); } }
if (includeContent && isFile) { try { byte[] bytes = Files.readBytes(file); content = toBase64(bytes); encoding = DEFAULT_ENCODING;
byte[] bytes = Files.readBytes(iconFile); byte[] encoded = Base64Encoder.encode(bytes);