@Override public <T> T parseAsStream( Class<T> type, byte[] value ) { return this.parse ( type, new InMemoryInputStream( value ) ); }
public int read(byte b[]) throws IOException { return read(b, 0, b.length); }
@Test public void test() { byte[] content = new String("123").getBytes(StandardCharsets.UTF_8); byte [] readBy = new byte[2]; InMemoryInputStream stream = new InMemoryInputStream(content); for (int index=0; index < 25; index++) { int read = stream.read(readBy, 0, readBy.length); puts(read, readBy, new String(readBy, StandardCharsets.UTF_8)); } } }
@Override public Object parseAsStream ( byte[] value ) { return this.parse( new InMemoryInputStream( value ) ); }
public int read(byte b[]) throws IOException { return read(b, 0, b.length); }
@Override public Object parseAsStream ( byte[] value ) { return this.parse( new InMemoryInputStream( value ) ); }
public int read(byte b[]) throws IOException { return read(b, 0, b.length); }
@Override public <T> T parseAsStream( Class<T> type, byte[] value ) { return this.parse ( type, new InMemoryInputStream( value ) ); }
@Override public <T> T parseAsStream( Class<T> type, byte[] value ) { return this.parse ( type, new InMemoryInputStream( value ) ); }
public <T> T parseAsStream( Class<T> type, byte[] value ) { return this.parse( type, new InMemoryInputStream( value ) ); }
public <T> T parseAsStream( Class<T> type, byte[] value ) { return this.parse( type, new InMemoryInputStream( value ) ); }
@Override public Object parseAsStream ( byte[] value ) { return this.parse( new InMemoryInputStream( value ) ); }
public <T> T parseAsStream( Class<T> type, byte[] value ) { return this.parse( type, new InMemoryInputStream( value ) ); }
@Override public final <T> T parseAsStream( Class<T> type, byte[] value ) { if (copyBuf==null) { copyBuf = new char[bufSize]; } charBuf = IO.read( new InputStreamReader ( new InMemoryInputStream(value), charset ), charBuf, value.length, copyBuf ); return this.basicParser.parse ( type, charBuf.readForRecycle () ); }
@Override public final <T> T parseAsStream( Class<T> type, byte[] value ) { if (copyBuf==null) { copyBuf = new char[bufSize]; } charBuf = IO.read( new InputStreamReader ( new InMemoryInputStream(value), charset ), charBuf, value.length, copyBuf ); return this.basicParser.parse ( type, charBuf.readForRecycle () ); }
@Override public final <T> T parseAsStream( Class<T> type, byte[] value ) { if (copyBuf==null) { copyBuf = new char[bufSize]; } charBuf = IO.read( new InputStreamReader ( new InMemoryInputStream(value), charset ), charBuf, value.length, copyBuf ); return this.basicParser.parse ( type, charBuf.readForRecycle () ); }
private void initSourceWithString(String testString) { ByteArrayInputStream inputStream = new InMemoryInputStream(testString.getBytes(StandardCharsets.UTF_8)); source = new ReaderCharacterSource ( new InputStreamReader(inputStream) ); }
private void initSourceWithString(String testString, int size) { ByteArrayInputStream inputStream = new InMemoryInputStream(testString.getBytes(StandardCharsets.UTF_8)); source = new ReaderCharacterSource ( new InputStreamReader(inputStream), size ); } @Test
@Test public void test() throws IOException { byte[] content = new String("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").getBytes(StandardCharsets.UTF_8); byte [] readBy = new byte[4]; InMemoryInputStream stream = new InMemoryInputStream(content); ioInputStream = IOInputStream.input(ioInputStream, 10).input(stream); for (int index=0; index < 25; index++) { int read = ioInputStream.read(readBy, 0, readBy.length); puts(read, readBy, new String(readBy, StandardCharsets.UTF_8)); } } }
@Test public void testReadWriteLinesCharSet() { ByteArrayOutputStream bos = new ByteArrayOutputStream(); IO.write( bos, "line 1\n", Charset.forName( "UTF-8" ) ); IO.write( bos, "apple\n", IO.DEFAULT_CHARSET ); IO.write( bos, "pear\n", IO.DEFAULT_CHARSET ); IO.write( bos, "grapes\n", IO.DEFAULT_CHARSET ); List<String> lines = IO.readLines( new InMemoryInputStream( bos.toByteArray() ) ); assertLines( lines ); }