本文整理匯總了Java中java.io.Reader.ready方法的典型用法代碼示例。如果您正苦於以下問題:Java Reader.ready方法的具體用法?Java Reader.ready怎麽用?Java Reader.ready使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.Reader
的用法示例。
在下文中一共展示了Reader.ready方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: gobble
import java.io.Reader; //導入方法依賴的package包/類
private static void gobble(InputStream is, Reader rd,
int ec, boolean force)
throws Exception
{
int a = is.available();
boolean r = rd.ready();
log.print("" + a + " bytes available, "
+ "reader " + (r ? "" : "not ") + "ready");
if (!r && !force) {
log.println();
return;
}
int c;
try {
c = rd.read();
} catch (InterruptedIOException x) {
log.println();
throw x;
}
log.println(", read() ==> "
+ (c >= 0 ? ("'" + (char)c + "'" ): "EOF"));
if (c != ec)
throw new Exception("Incorrect value read: Expected "
+ ec + ", read " + (char)c);
}
示例2: read
import java.io.Reader; //導入方法依賴的package包/類
private int read(Reader is, char[] buff, int start, int count)
throws InterruptedException, IOException {
while (!is.ready() && !done) {
sleep(100);
}
return is.read(buff, start, count);
}
示例3: ready
import java.io.Reader; //導入方法依賴的package包/類
@Override
public boolean ready() throws PogamutIOException {
try {
if (!controller.isRunning()) return false;
Reader currentReader = this.getReader();
if (currentReader != null) return currentReader.ready();
} catch (Exception e) {
handleException(e);
}
return false;
}