Java PipedInputStream receive()方法与示例
PipedInputStream类的receive()方法 (PipedInputStream Class receive() method)
receive() method is available in java.io package.
receive()方法在java.io包中可用。
receive() method is used to receive a byte of content and it will block when no more input remains.
receive()方法用于接收内容的一个字节,当不再有剩余输入时它将阻塞。
receive() 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.
receive()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
receive() method may throw an exception at the time of receiving a byte of data.
receive()方法在接收到一个字节数据时可能会引发异常。
IOException: This exception may throw when getting any input/output error or pipe not connected properly, or stream closed.
IOException :当出现任何输入/输出错误或管道未正确连接或流关闭时,可能引发此异常。
Syntax:
句法:
protected void receive(int byt);
Parameter(s):
参数:
int byt – represents the byte getting received.
int byt –表示要接收的字节。
Return value:
返回值:
The return type of the method is void, it returns nothing.
该方法的返回类型为void ,不返回任何内容。
Example:
例:
// Java program to demonstrate the example
// of receive(int byt) method of PipedInputStream
import java.io.*;
public class ReceiveOfPIS extends PipedInputStream {public static void main(String[] args) throws Exception {int val = 65;
try {// Instantiates ReceiveOfPIS and
// PipedOutputStream
ReceiveOfPIS pipe_in = new ReceiveOfPIS();
PipedOutputStream pipe_out = new PipedOutputStream();
// By using connect() method is to
// connect this pipe_in to the given pipe_out
pipe_in.connect(pipe_out);
for (int i = 0; i < 3; ++i) {// By using write() method is to
// write the val to the stream pipe_out
pipe_out.write(val);
val++;
}
for (int i = 1; i < 4; ++i) {// By using receive() method is to
// receive a byte
pipe_in.receive(val);
System.out.println(i + " " + "Byte Received ");
}
// By using close() method is to close
// the stream
pipe_in.close();
pipe_out.close();
} catch (Exception ex) {System.out.println(ex.toString());
}
}
}
Output
输出量
1 Byte Received
2 Byte Received
3 Byte Received
翻译自: https://www.includehelp.com/java/pipedinputstream-receive-method-with-example.aspx
Java PipedInputStream receive()方法与示例相关推荐
- java receive_Java PipedInputStream receive()方法与示例
PipedInputStream类receive()方法receive()方法在java.io包中可用. receive()方法用于接收内容的一个字节,当不再有剩余输入时它将阻塞. receive() ...
- Java IOUtils.copy方法代码示例(亲测)
本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...
- java user directory,Java ProcessBuilder directory()方法与示例
语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...
- Java序列化魔术方法及其示例使用
在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...
- catalog java,Java Connection getCatalog()方法与示例
通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...
- filepermission java,Java FilePermission getActions()方法与示例
FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...
- java方法参数Bundle,Java ResourceBundle keySet()方法及示例
ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...
- java exec waitfor,Java Process waitFor()方法与示例
流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...
- java arraylist.add(),Java ArrayList add()方法与示例
ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...
最新文章
- 卷积神经网络(CNN)_相关知识
- 李洪强经典面试题10
- 领域驱动设计DDD实战进阶第一波(十四):开发一般业务的大健康行业直销系统(订单上下文应用服务用例与接口)...
- 编辑函数求n阶乘fact_n!函数用C语言其实可以这样!
- 设计模式示例_桥梁设计模式示例
- 安装Nginx到linux服务器(Ubuntu)详解
- matlab如何判断矩阵中元素都大于0_在MATLAB中找到矩阵中零元素的数量
- 阶段3 2.Spring_03.Spring的 IOC 和 DI_13 课程知识梳理
- 快速学习navicat安装教程
- nodejs mysql嵌套查询_nodejs+mysql嵌套查询的问题
- 面试通过了,也给了Offer,不去有什么后果?
- 从零开始了解推荐系统全貌
- Android开发EditText属性
- Web前端工程师就业前景怎么样?整体薪资待遇好不好?
- D3基本图表绘制——折线图
- 天融信 还有什么型号服务器,天融信日志服务器
- 迪兰恒进 RX550 2G 超能 驱动黑苹果macOS 10. 15
- VMware 安装CentOS以及安装多个linux系统
- python调音_Linux实现远程控制ALSA调音台?!
- 既然江郎才尽,就上几张俺新宠物的pp上来showshow好了
热门文章
- python气象_Python 在气象上的应用
- pyecharts 间距_高月双色球20108期:红球首尾间距参考29区段
- Oracle里silent,静默方式(silent)安装Oracle软件
- Python二级笔记(12)
- html json to table,javascript - HTML - Convert json to table - Stack Overflow
- 软件测试用例_软件测试用例设计实战场景法
- 02-go的IDE安装
- 14-容器网络之host和none
- 精华阅读第6期|程序猿的世界,你不懂!
- iOS开发-自定义UIAlterView(iOS 7)