@Test public void testToByteArray1() { byte[] testArray = new byte[Byte.MAX_VALUE - Byte.MIN_VALUE]; for (int i = Byte.MIN_VALUE; i < Byte.MAX_VALUE; i++) { testArray[i - Byte.MIN_VALUE] = (byte) i; } try { byte[] result = IOUtil.toByteArray(new ByteArrayInputStream(testArray)); assertTrue(Arrays.equals(testArray, result)); } catch (IOException e) { e.printStackTrace(); assertTrue(false); } }
public static byte[] toByteArray(Reader in, String encoding) throws IOException { StringWriter out = new StringWriter(); copy(in, out); out.flush(); return out.toString().getBytes(encoding); }
IOUtil { public static byte[] toByteArray(Reader in, String encoding) throws IOException { StringWriter out = new StringWriter(); copy(in, out); out.flush(); return out.toString().getBytes(encoding); } }
IOUtil { public static byte[] toByteArray(Reader in, String encoding) throws IOException { StringWriter out = new StringWriter(); copy(in, out); out.flush(); return out.toString().getBytes(encoding); }  }
IOUtil { public static byte[] toByteArray(Reader in, String encoding) throws IOException { StringWriter out = new StringWriter(); copy(in, out); out.flush(); return out.toString().getBytes(encoding); }  static byte[] toByteArray(Reader in, String encoding); static byte[] toByteArray(InputStream in); static byte[] toByteArray( InputStream in, int size ); static int copy(InputStream in, OutputStream out); static int copy(Reader in, Writer out); }
IOUtil { public static byte[] toByteArray(Reader in, String encoding) throws IOException { StringWriter out = new StringWriter(); copy(in, out); out.flush(); return out.toString().getBytes(encoding); }  static byte[] toByteArray(Reader in, String encoding); static byte[] toByteArray(InputStream in); static byte[] toByteArray( InputStream in, int size ); static int copy(InputStream in, OutputStream out); static int copy(Reader in, Writer out); static final int IO_COPY_BUFFER_SIZE; }