@Override public boolean ready() throws IOException { return (current != null) && current.ready(); }
@Override public boolean ready() throws IOException { return (current != null) && current.ready(); }
@Override public boolean ready() throws IOException { return (current != null) && current.ready(); }
@Override public boolean ready() throws IOException { if (limit > 0) { return r.ready(); } return false; }
@Override public boolean ready() throws IOException { return (current != null) && current.ready(); }
@Override public boolean ready() throws IOException { return wrappedReader.ready(); }
public boolean ready() throws java.io.IOException { return in.ready(); }
/** @see java.io.Reader#ready() */ public boolean ready() throws IOException { return in.ready(); }
/** * Indicates whether this reader is ready to be read without blocking. If * the result is {@code true}, the next {@code read()} will not block. If * the result is {@code false}, this reader may or may not block when * {@code read()} is sent. * * @return {@code true} if this reader will not block when {@code read()} * is called, {@code false} if unknown or blocking will occur. * @throws IOException * if the reader is closed or some other I/O error occurs. */ @Override public boolean ready() throws IOException { synchronized (lock) { return in.ready(); } }
/** * @return the current number of bytes ready for reading * @exception IOException if an error occurs */ public synchronized int available() throws IOException { if (in == null) { throw new IOException("Stream Closed"); } if (slack != null) { return slack.length - begin; } if (in.ready()) { return 1; } else { return 0; } }
@Override public boolean ready() throws IOException { // assuming no other thread is concurrently reading if (readers.isEmpty()) { return false; } return readers.getFirst().ready(); }
/** * Invokes the delegate's <code>ready()</code> method. * @return true if the stream is ready to be read * @throws IOException if an I/O error occurs */ @Override public boolean ready() throws IOException { try { return in.ready(); } catch (final IOException e) { handleIOException(e); return false; } }
/** * @return the current number of bytes ready for reading * @exception IOException if an error occurs */ @Override public synchronized int available() throws IOException { if (in == null) { throw new IOException("Stream Closed"); } if (slack != null) { return slack.length - begin; } if (in.ready()) { return 1; } return 0; }
/** * Reads all text up to next XML tag and returns it as a String. * * @return the String of the text read, which may be empty. */ public static String readUntilTag(Reader r) throws IOException { if (!r.ready()) { return ""; } StringBuilder b = new StringBuilder(); int c = r.read(); while (c >= 0 && c != '<') { b.append((char) c); c = r.read(); } return b.toString(); }
/** * Reads all text of the XML tag and returns it as a String. * Assumes that a '<' character has already been read. * * @param r The reader to read from * @return The String representing the tag, or null if one couldn't be read * (i.e., EOF). The returned item is a complete tag including angle * brackets, such as {@code <TXT>} */ public static String readTag(Reader r) throws IOException { if ( ! r.ready()) { return null; } StringBuilder b = new StringBuilder("<"); int c = r.read(); while (c >= 0) { b.append((char) c); if (c == '>') { break; } c = r.read(); } if (b.length() == 1) { return null; } return b.toString(); }
@Override public int available() throws IOException { int i = pis.available(); if (i > 0) { return i; } if (reader.ready()) { // Char must produce at least one byte. return 1; } else { return 0; } }
@Override public boolean available() throws GuacamoleException { try { return input.ready() || usedLength != 0; } catch (IOException e) { throw new GuacamoleServerException(e); } }
@Override public boolean ready() throws IOException { adversary.injectFailure( IOException.class ); return 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()); }
@Test public void testSunnyDay() throws Exception { Reader reader = null; try { String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; ReaderEditor editor = new ReaderEditor(); editor.setAsText(resource); Object value = editor.getValue(); assertNotNull(value); assertTrue(value instanceof Reader); reader = (Reader) value; assertTrue(reader.ready()); } finally { if (reader != null) { reader.close(); } } }