java.io.InputStreamReader.ready()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(184)

本文整理了Java中java.io.InputStreamReader.ready()方法的一些代码示例,展示了InputStreamReader.ready()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InputStreamReader.ready()方法的具体详情如下:
包路径:java.io.InputStreamReader
类名称:InputStreamReader
方法名:ready

InputStreamReader.ready介绍

[英]Indicates whether this reader is ready to be read without blocking. If the result is true, the next read() will not block. If the result is false then this reader may or may not block when read() is called. This implementation returns true if there are bytes available in the buffer or the source stream has bytes available.
[中]指示此读卡器是否已准备好在不阻塞的情况下读取。如果结果为true,则下一个read()将不会阻塞。如果结果为false,则调用read()时,该读取器可能会阻塞,也可能不会阻塞。如果缓冲区中有可用字节,或者源流中有可用字节,则此实现返回true。

代码示例

代码示例来源:origin: com.thoughtworks.xstream/xstream

/**
 * @see java.io.Reader#ready()
 */
public boolean ready() throws IOException {
  return reader.ready();
}

代码示例来源:origin: jamesagnew/hapi-fhir

private void next() throws IOException, FHIRException {
 finished = !reader.ready();
 if (!finished) {
  char[] temp = new char[1];
  rule(reader.read(temp, 0, 1) == 1, "unable to read 1 character from the stream");
  peeked = temp[0];
 } 
}

代码示例来源:origin: jamesagnew/hapi-fhir

private String readSource() throws IOException  {
 StringBuilder s = new StringBuilder();
 InputStreamReader r = new InputStreamReader(source,"UTF-8");
 while (r.ready()) {
  s.append((char) r.read()); 
 }
 r.close();
 return s.toString();
}

代码示例来源:origin: winder/Universal-G-Code-Sender

/**
 * Thread to accept data from remote host, and pass it to responseHandler
 */
public void run() {
  String resp;
  while(!Thread.interrupted() && !client.isClosed())
  {
    try {
      if(inStream.ready() && (resp = bufIn.readLine()) != null) {
        responseMessageHandler.handleResponse(resp + "\n", comm);
      }
    } catch (SocketException e) {
      e.printStackTrace();
      return; // terminate thread if disconnected
          //TODO: at some point, reconnecting should be considered
    } catch (IOException e) {
      e.printStackTrace();
      return; // terminate thread if disconnected
          //TODO: at some point, reconnecting should be considered
    }
  }
}

代码示例来源:origin: org.sonatype.nexus.xstream/xstream

/**
 * @see java.io.Reader#ready()
 */
public boolean ready() throws IOException {
  return reader.ready();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream

/**
 * @see java.io.Reader#ready()
 */
public boolean ready() throws IOException {
  return reader.ready();
}

代码示例来源:origin: org.jvnet.hudson/xstream

/**
 * @see java.io.Reader#ready()
 */
public boolean ready() throws IOException {
  return reader.ready();
}

代码示例来源:origin: OpenSmpp/opensmpp

/**
 * Returns if end of the stream was already reached.
 */
boolean eof() throws IOException {
  return !in.ready();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream-java8

/**
 * @see java.io.Reader#ready()
 */
public boolean ready() throws IOException {
  return reader.ready();
}

代码示例来源:origin: com.haulmont.thirdparty/xstream

/**
 * @see java.io.Reader#ready()
 */
public boolean ready() throws IOException {
  return reader.ready();
}

代码示例来源:origin: ovea-deprecated/jetty-session-redis

/**
 * @see java.io.Reader#ready()
 */
public boolean ready() throws IOException {
  return reader.ready();
}

代码示例来源:origin: OpenGamma/Strata

@Override
public boolean ready() throws IOException {
 return underlying.ready();
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * @see java.io.Reader#ready()
 */
public boolean ready() throws IOException {
  return reader.ready();
}

代码示例来源:origin: stackoverflow.com

FileReader fr = new FileReader("somefile");
// ... file reader activity
fr.close();

// After closing the reader, the ready() method should cause an IOException:
boolean isOpen = true;
try {
 isOpen = fr.ready();
} catch (IOException e) {
 isOpen = false;
}
assertFalse("FileReader is still open", isOpen);

代码示例来源:origin: stackoverflow.com

FileReader br = new FileReader(file);
 if(br.ready())
 return;
 else
 System.exit(1);

代码示例来源:origin: stackoverflow.com

try
{
InputStreamReader reader = new InputStreamReader(System.in);
while (!reader.ready()) { Thread.sleep(100); }
if (reader.read() > 0) { // interrupt this step and proceed to the next one }
}
catch (IOException e) { // do something }
catch (InterruptedException e) { // noone needs me anymore }

代码示例来源:origin: ca.uhn.hapi.fhir/hapi-fhir-utilities

private String readSource() throws IOException  {
 StringBuilder s = new StringBuilder();
 InputStreamReader r = new InputStreamReader(source,"UTF-8");
 while (r.ready()) {
  s.append((char) r.read()); 
 }
 r.close();
 return s.toString();
}

代码示例来源:origin: stackoverflow.com

InputStreamReader reader = new InputStreamReader(
    yourInputStream, "windows-1252"); 
    // or what ever seems to be the correct encoding!

StringBuilder builder = new StringBuilder();

while (reader.ready())
{
  builder.append(reader.read());
}
reader.close();

String string = builder.toString();

代码示例来源:origin: medallia/Word2VecJava

@Override public boolean ready() throws IOException {
    init();
    return internalIn2.ready();
  }
}

代码示例来源:origin: com.medallia.word2vec/word2vecjava

@Override public boolean ready() throws IOException {
    init();
    return internalIn2.ready();
  }
}

相关文章