/** * Reads the contents of a reader into a string. * * @param in The input reader. * @return The contents of the reader as a string. * @throws IOException If a problem occurred trying to read from the reader. */ public static String read(Reader in) throws IOException { return read(in, 0, 1024); }
/** * Read the specified file into a byte array. * * @param in * The file to read into a byte array. * @return The contents of the file as a byte array. * @throws IOException Thrown by underlying stream. */ public static byte[] readBytes(File in) throws IOException { return readBytes(in, 1024); }
@ResponseBody @Override /* Writeable */ public Writer writeTo(Writer w) throws IOException { for (Object o : contents) pipe(o, w); return w; }
/** * Writes the specified string to the specified file. * * @param path The file path. * @param contents The new file contents. * @throws IOException */ public static void write(String path, String contents) throws IOException { write(new File(path), new StringReader(contents)); }
/** * Create an instance of this class loaded from the contents of a reader. * * <p> * Note that the input must end in a newline to pick up the last line! * * @param r The manifest file contents. * @throws IOException If a problem occurred while trying to read the manifest file. */ public ManifestFile(Reader r) throws IOException { load(new Manifest(IOUtils.toInputStream(r))); }
@ResponseBody @Override /* Writeable */ public Writer writeTo(Writer w) throws IOException { for (Object o : contents) pipe(o, w); return w; }
/** * Writes the specified string to the specified file. * * @param path The file path. * @param contents The new file contents. * @throws IOException */ public static void write(String path, String contents) throws IOException { write(new File(path), new StringReader(contents)); }
@Override public InputStream getInput() throws Exception { return IOUtils.toInputStream("foobar"); } }
/** * Reads the contents of a reader into a string. * * @param in The input reader. * @return The contents of the reader as a string. * @throws IOException If a problem occurred trying to read from the reader. */ public static String read(Reader in) throws IOException { return read(in, 0, 1024); }
/** * Read the specified file into a byte array. * * @param in * The file to read into a byte array. * @return The contents of the file as a byte array. * @throws IOException Thrown by underlying stream. */ public static byte[] readBytes(File in) throws IOException { return readBytes(in, 1024); }
@ResponseBody @Override /* Writeable */ public Writer writeTo(Writer w) throws IOException { for (Object o : contents) pipe(o, w); return w; }
/** * Writes the specified string to the specified file. * * @param path The file path. * @param contents The new file contents. * @throws IOException */ public static void write(String path, String contents) throws IOException { write(new File(path), new StringReader(contents)); }
/** * Create an instance of this class loaded from the contents of a reader. * * <p> * Note that the input must end in a newline to pick up the last line! * * @param r The manifest file contents. * @throws IOException If a problem occurred while trying to read the manifest file. */ public ManifestFile(Reader r) throws IOException { load(new Manifest(IOUtils.toInputStream(r))); }
/** * Reads the contents of a file into a string. * * @param path The path of the file to read using default character encoding. * @return The contents of the reader as a string, or <jk>null</jk> if file does not exist. * @throws IOException If a problem occurred trying to read from the reader. */ public static String readFile(String path) throws IOException { return read(new File(path)); }
/** * Read the specified input stream into a byte array. * * @param in * The stream to read into a byte array. * @return The contents of the stream as a byte array. * @throws IOException Thrown by underlying stream. */ public static byte[] readBytes(InputStream in) throws IOException { return readBytes(in, 1024); }
@ResponseBody @Override /* Streamable */ public void streamTo(OutputStream os) throws IOException { for (Object c : contents) pipe(c, os); os.flush(); }