Package java.io

Examples of java.io.Reader.ready()


  public void testReady() throws Exception {
    CharSource source = newCharSource("a");
    Iterable<? extends CharSource> list = ImmutableList.of(source, source);
    Reader joinedReader = CharSource.concat(list).openStream();

    assertTrue(joinedReader.ready());
    assertEquals('a', joinedReader.read());
    assertEquals('a', joinedReader.read());
    assertEquals(-1, joinedReader.read());
    assertFalse(joinedReader.ready());   
  }
View Full Code Here


    assertTrue(joinedReader.ready());
    assertEquals('a', joinedReader.read());
    assertEquals('a', joinedReader.read());
    assertEquals(-1, joinedReader.read());
    assertFalse(joinedReader.ready());   
  }

  public void testSimple() throws Exception {
    String testString = "abcdefgh";
    CharSource source = newCharSource(testString);
View Full Code Here

    // -----------------------------------------------------------------------
    public void testAsReader() throws Exception {
        StrBuilder sb = new StrBuilder("some text");
        Reader reader = sb.asReader();
        assertEquals(true, reader.ready());
        char[] buf = new char[40];
        assertEquals(9, reader.read(buf));
        assertEquals("some text", new String(buf, 0, 9));
       
        assertEquals(-1, reader.read());
View Full Code Here

        char[] buf = new char[40];
        assertEquals(9, reader.read(buf));
        assertEquals("some text", new String(buf, 0, 9));
       
        assertEquals(-1, reader.read());
        assertEquals(false, reader.ready());
        assertEquals(0, reader.skip(2));
        assertEquals(0, reader.skip(-1));
       
        assertEquals(true, reader.markSupported());
        reader = sb.asReader();
View Full Code Here

        assertEquals('o', array[1]);
        assertEquals('e', array[2]);
        assertEquals(2, reader.skip(2));
        assertEquals(' ', reader.read());
       
        assertEquals(true, reader.ready());
        reader.close();
        assertEquals(true, reader.ready());
       
        reader = sb.asReader();
        array = new char[3];
View Full Code Here

        assertEquals(2, reader.skip(2));
        assertEquals(' ', reader.read());
       
        assertEquals(true, reader.ready());
        reader.close();
        assertEquals(true, reader.ready());
       
        reader = sb.asReader();
        array = new char[3];
        try {
            reader.read(array, -1, 0);
View Full Code Here

    // -----------------------------------------------------------------------
    public void testAsReader() throws Exception {
        StrBuilder sb = new StrBuilder("some text");
        Reader reader = sb.asReader();
        assertEquals(true, reader.ready());
        char[] buf = new char[40];
        assertEquals(9, reader.read(buf));
        assertEquals("some text", new String(buf, 0, 9));
       
        assertEquals(-1, reader.read());
View Full Code Here

        char[] buf = new char[40];
        assertEquals(9, reader.read(buf));
        assertEquals("some text", new String(buf, 0, 9));
       
        assertEquals(-1, reader.read());
        assertEquals(false, reader.ready());
        assertEquals(0, reader.skip(2));
        assertEquals(0, reader.skip(-1));
       
        assertEquals(true, reader.markSupported());
        reader = sb.asReader();
View Full Code Here

        assertEquals('o', array[1]);
        assertEquals('e', array[2]);
        assertEquals(2, reader.skip(2));
        assertEquals(' ', reader.read());
       
        assertEquals(true, reader.ready());
        reader.close();
        assertEquals(true, reader.ready());
       
        reader = sb.asReader();
        array = new char[3];
View Full Code Here

        assertEquals(2, reader.skip(2));
        assertEquals(' ', reader.read());
       
        assertEquals(true, reader.ready());
        reader.close();
        assertEquals(true, reader.ready());
       
        reader = sb.asReader();
        array = new char[3];
        try {
            reader.read(array, -1, 0);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.