/** * Copies specified number of bytes from input stream to writer using buffer. */ public static void copy(InputStream input, Writer output, int byteCount) throws IOException { copy(input, output, JoddCore.encoding, byteCount); } /**
/** * Copies reader to output stream using buffer. */ public static void copy(Reader input, OutputStream output) throws IOException { copy(input, output, JoddCore.encoding); } /**
/** * Copies input stream to writer using buffer. */ public static void copy(InputStream input, Writer output) throws IOException { copy(input, output, JoddCore.encoding); } /**
/** * Copies input stream to writer using buffer and specified encoding. */ public static void copy(InputStream input, Writer output, String encoding) throws IOException { copy(new InputStreamReader(input, encoding), output); } /**
/** * Copies specified number of bytes from input stream to writer using buffer and specified encoding. */ public static void copy(InputStream input, Writer output, String encoding, int byteCount) throws IOException { copy(new InputStreamReader(input, encoding), output, byteCount); }
/** * Copies specified number of characters from reader to output stream using buffer and specified encoding. */ public static void copy(Reader input, OutputStream output, String encoding, int charCount) throws IOException { Writer out = new OutputStreamWriter(output, encoding); copy(input, out, charCount); out.flush(); }
/** * Copies reader to output stream using buffer and specified encoding. */ public static void copy(Reader input, OutputStream output, String encoding) throws IOException { Writer out = new OutputStreamWriter(output, encoding); copy(input, out); out.flush(); } /**
/** * Reads path content. */ public static String readString(Path path) throws IOException { BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8); StringWriter writer = new StringWriter(); StreamUtil.copy(reader, writer); return writer.toString(); }
public static void writeStream(String dest, InputStream in) throws IOException { FileOutputStream out = null; try { out = new FileOutputStream(dest); StreamUtil.copy(in, out); } finally { StreamUtil.close(out); } }
public static void writeStream(File dest, InputStream in) throws IOException { FileOutputStream out = null; try { out = new FileOutputStream(dest); StreamUtil.copy(in, out); } finally { StreamUtil.close(out); } }
public static byte[] readBytes(InputStream input) throws IOException { FastByteArrayOutputStream output = new FastByteArrayOutputStream(); copy(input, output); return output.toByteArray(); } public static byte[] readBytes(InputStream input, int byteCount) throws IOException {
public static byte[] readBytes(Reader input, int byteCount) throws IOException { FastByteArrayOutputStream output = new FastByteArrayOutputStream(); copy(input, output, byteCount); return output.toByteArray(); } public static byte[] readBytes(Reader input, String encoding) throws IOException {
public static char[] readChars(InputStream input, int charCount) throws IOException { FastCharArrayWriter output = new FastCharArrayWriter(); copy(input, output, charCount); return output.toCharArray(); }
public static byte[] readBytes(InputStream input, int byteCount) throws IOException { FastByteArrayOutputStream output = new FastByteArrayOutputStream(); copy(input, output, byteCount); return output.toByteArray(); }
public static byte[] readBytes(Reader input, String encoding, int byteCount) throws IOException { FastByteArrayOutputStream output = new FastByteArrayOutputStream(); copy(input, output, encoding, byteCount); return output.toByteArray(); }
public static char[] readChars(InputStream input) throws IOException { FastCharArrayWriter output = new FastCharArrayWriter(); copy(input, output); return output.toCharArray(); } public static char[] readChars(InputStream input, int charCount) throws IOException {
public static char[] readChars(InputStream input, String encoding) throws IOException { FastCharArrayWriter output = new FastCharArrayWriter(); copy(input, output, encoding); return output.toCharArray(); } public static char[] readChars(InputStream input, String encoding, int charCount) throws IOException {
public static char[] readChars(InputStream input, String encoding, int charCount) throws IOException { FastCharArrayWriter output = new FastCharArrayWriter(); copy(input, output, encoding, charCount); return output.toCharArray(); }
public static byte[] readBytes(Reader input, String encoding) throws IOException { FastByteArrayOutputStream output = new FastByteArrayOutputStream(); copy(input, output, encoding); return output.toByteArray(); } public static byte[] readBytes(Reader input, String encoding, int byteCount) throws IOException {
public static char[] readChars(Reader input, int charCount) throws IOException { FastCharArrayWriter output = new FastCharArrayWriter(); copy(input, output, charCount); return output.toCharArray(); }