PushbackReader类ready()方法 (PushbackReader Class ready() method)

  • ready() method is available in java.io package.

    ready()方法在java.io包中可用。

  • ready() method is used to check whether this stream is ready to be read or not.

    ready()方法用于检查此流是否已准备好被读取。

  • ready() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    ready()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • ready() method may throw an exception at the time of checking the state of the stream.

    在检查流的状态时, ready()方法可能会引发异常。

    IOException: This exception may throw when getting any input/output error while performing.

    IOException :在执行过程中遇到任何输入/输出错误时,可能引发此异常。

Syntax:

句法:

    public boolean ready();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is boolean, it returns true when input data is exists for the next read without blocking otherwise it returns false.

该方法的返回类型为boolean ,如果存在下一次​​读取的输入数据且没有阻塞,则返回true,否则返回false。

Example:

例:

// Java program to demonstrate the example
// of boolean ready() method of
// PushbackReader
import java.io.*;
public class ReadyOfPBR {public static void main(String[] args) throws Exception {Reader r_stm = null;
PushbackReader pb_r = null;
try {// Instantiates Reader and PushbackReader
r_stm = new StringReader("Java World!!!!");
pb_r = new PushbackReader(r_stm);
// By using ready() method is to
// check whether this stream is ready to
// be read or not
boolean status = pb_r.ready();
System.out.println("pb_r.ready(): " + status);
} catch (Exception ex) {System.out.println(ex.toString());
} finally {// with the help of this block is to
// free all necessary resources linked
// with the stream
if (r_stm != null) {r_stm.close();
if (pb_r != null) {pb_r.close();
}
}
}
}
}

Output

输出量

pb_r.ready(): true

翻译自: https://www.includehelp.com/java/pushbackreader-ready-method-with-example.aspx

Java PushbackReader ready()方法与示例相关推荐

  1. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  2. java中skip是什么意思_Java PushbackReader skip()方法与示例

    PushbackReader类skip()方法skip()方法在java.io包中可用. skip()方法用于从此PushbackReader流中跳过给定数量的字符,它将阻塞直到存在某些字符输入或发生 ...

  3. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  4. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  5. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

  6. filepermission java,Java FilePermission getActions()方法与示例

    FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...

  7. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

  8. java exec waitfor,Java Process waitFor()方法与示例

    流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...

  9. java arraylist.add(),Java ArrayList add()方法与示例

    ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...

最新文章

  1. 基于RESTful API 怎么设计用户权限控制?
  2. php $globa作用是l,php 关键字global在定义变量中的作用
  3. java上传的文件没有,java – 文件未上传到服务器
  4. php umount强制,php foreach 參數強制類型轉換的問題 | 學步園
  5. [CQOI2014]数三角形 题解(找规律乱搞)
  6. 苹果挖角Waymo无人车系统主管,奇女子一枚,曾把车开上火星
  7. c 语言编写个人所得税程序,C语言编写一个计算个人所得税的程序,要求输入收入金额,能够输...
  8. 保存的离线网页总是自动跳转怎么办???
  9. html下播放.wav,wav格式文件用什么播放
  10. Scrapy爬虫项目的创建及案例
  11. Java二叉树数据结构原理
  12. 在Mac上将移动磁盘格式化为FAT32分区
  13. bzoj1050: [HAOI2006]旅行comf
  14. 舆情分析报告写作的架构与方法|下
  15. 自制一个简单的音乐播放器
  16. air换电池 macbook_大加分!苹果 2018 新款 MacBook Air 电池可独立更换
  17. GD32 ADC功能及代码详解
  18. 各代iPhone iPad 内部代号 Hardware Model
  19. ELK应用之Logstash 数据转换
  20. GetLastError错误码中文大全

热门文章

  1. 实战|全程分析js到getshell
  2. ext3 tree tbar 初始化定义
  3. suse linux安装rpm包,linux – 如何为Suse创建RPM
  4. 超大超长图片居中显示且放大缩小无影响
  5. 【转】前端开发值得一看的文章
  6. 有一本书,适合零到十年经验的程序员看
  7. Html和websocket初识
  8. 利用css transition属性实现一个带动画显隐的微信小程序部件
  9. 创建vue项目(四)路由相关知识、路由守卫、插槽、打包小细节
  10. PJMEDIA之录音器的使用(capture sound to avi file)