UnsyncBufferedReader extends Reader { @Override public boolean ready() throws IOException { if (_reader == null) { throw new IOException("Reader is null"); } if ((_index < _firstInvalidIndex) || _reader.ready()) { return true; } return false; } UnsyncBufferedReader(Reader reader);  UnsyncBufferedReader(Reader reader, int size); @Override void close(); @Override void mark(int markLimit); @Override boolean markSupported(); @Override int read(); @Override int read(char[] chars); @Override int read(char[] chars, int offset, int length); String readLine(); @Override boolean ready(); @Override void reset(); @Override long skip(long skip);  }
@Override @Test public void testReady() throws IOException { UnsyncBufferedReader unsyncBufferedReader = new UnsyncBufferedReader( new StringReader("")); Assert.assertTrue(unsyncBufferedReader.ready()); unsyncBufferedReader = new UnsyncBufferedReader( new InputStreamReader(new ByteArrayInputStream(new byte[0]))); Assert.assertFalse(unsyncBufferedReader.ready()); unsyncBufferedReader = new UnsyncBufferedReader( new StringReader("abcd") { @Override public int read(char[] chars, int offset, int length) throws IOException { _ready = false; return super.read(chars, offset, length); } @Override public boolean ready() { return _ready; } private boolean _ready = true; }); char[] chars = new char[2]; Assert.assertEquals(2, unsyncBufferedReader.read(chars)); Assert.assertEquals("ab", new String(chars)); unsyncBufferedReader.mark(2); Assert.assertTrue(unsyncBufferedReader.ready()); }