pipedreader_Java PipedReader connect()方法与示例

pipedreader

PipedReader类的connect()方法 (PipedReader Class connect() method)

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

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

  • connect() method is used to cause this PipedReader to be connected to the given PipedWriter (source) when this PipedReader is not previously connected to any of the other PipedWriter.

    当此PipedReader先前未连接到任何其他PipedWriter时,使用connect()方法使此PipedReader连接到给定的PipedWriter(源)。

  • connect() 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.

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

  • connect() method may throw an exception at the time of connecting the stream.

    connect()方法在连接流时可能会引发异常。

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

    IOException :遇到任何输入/输出错误时,可能引发此异常。

Syntax:

句法:

    public void connect(PipedWriter source);

Parameter(s):

参数:

  • PipedWriter source – represents the piped writer to connect to this PipedReader.

    PipedWriter源 –表示连接到此PipedReader的管道编写器。

Return value:

返回值:

The return type of the method is void, it returns nothing.

该方法的返回类型为void ,不返回任何内容。

Example:

例:

// Java program to demonstrate the example 
// of void connect(PipedWriter source) method of 
// PipedReader
import java.io.*;
public class ConnectOfPR {
public static void main(String[] args) throws Exception {
int val = 65;
try {
// Instantiates PipedReader and PipedWriter
PipedWriter pipe_w = new PipedWriter();
PipedReader pipe_r = new PipedReader();
// By using connect() method is to connect
// this pipe_r to the given pipe_w
pipe_r.connect(pipe_w);
for (int i = 0; i < 3; ++i) {
// By using write() method is to
// write the val to the stream pipe_w
pipe_w.write(val);
val++;
}
for (int i = 0; i < 3; ++i) {
// By using read() method is to
// read the integer and convert it into
// char
char ch = (char) pipe_r.read();
System.out.println("pipe_r.read(): " + ch);
}
// By using close() method is to close
// the stream
pipe_w.close();
pipe_w.close();
} catch (Exception ex) {
System.out.println(ex.toString());
}
}
}

Output

输出量

pipe_r.read(): A
pipe_r.read(): B
pipe_r.read(): C

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

pipedreader

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541504.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

《Java学习指南》—— 1.4 设计安全

本节书摘来异步社区《Java学习指南》一书中的第1章&#xff0c;第1.4节&#xff0c;作者&#xff1a;【美】Patrick Niemeyer , Daniel Leuck&#xff0c;更多章节内容可以访问云栖社区“异步社区”公众号查看。 1.4 设计安全 Java被设计为一种安全语言&#xff0c;对于这一事实…

ppython_Python pcom包_程序模块 - PyPI - Python中文网

PCOM在python中一个非常基本的unitronics pcom协议实现。如何使用from pcom import commandsfrom pcom.plc import EthernetPlcwith EthernetPlc(address(192.168.5.43, 1616)) as plc:# Read realtime clockc commands.ReadRtc()res plc.send(c)print(res)# Set realtime cl…

bitcount方法详解_Java Long类的bitCount()方法和示例

bitcount方法详解长类bitCount()方法 (Long class bitCount() method) bitCount() method is available in java.lang package. bitCount()方法在java.lang包中可用。 bitCount() method is used to find the number of 1s bits in the 2s complement binary denotation of the…

《软件定义数据中心:Windows Server SDDC技术与实践》——导读

前言 通过对自身的审视和对身边IT 技术专家的观察&#xff0c;我发现对于我们来说&#xff0c;掌握一项新的技术或熟悉一个新的产品&#xff0c;大都是闻而后知&#xff0c;知而后学&#xff0c;学以致用&#xff0c;用以知其然。然而Windows Server作为一个简单的、易上手的操…

python二维向量运算模拟_python二维向量运算_[VB.NET][C#]二维向量的基本运算

前言在数学中&#xff0c;几何向量是指具有大小和方向的几何对象。在编程中&#xff0c;向量有着广泛的应用&#xff0c;其作用在图形编程和游戏物理引擎方面尤为突出。第一节 构造函数通过创建一个二维向量的类(或结构体)&#xff0c;实现向量的表示及其运算。1. 首先&#xf…

Java LinkedHashMap clear()方法与示例

LinkedHashMap类的clear()方法 (LinkedHashMap Class clear() method) clear() method is available in java.util package. clear()方法在java.util包中可用。 clear() method is used to remove all the existing elements from this LinkedHashMap. clear()方法用于从此Link…

《Imperfect C++中文版》——1.3 运行期契约:前置条件、后置条件和不变式

本节书摘来自异步社区出版社《Imperfect C中文版》一书中的第1章&#xff0c;第1.3节&#xff0c;作者&#xff1a; 【美】Matthew Wilson&#xff0c;更多章节内容可以访问云栖社区“异步社区”公众号查看。 1.3 运行期契约&#xff1a;前置条件、后置条件和不变式 Imperfect …

python名称空间与运用域_Python名称空间和作用域讲座,命名,Namespaces,Scopes

Python命名空间(Namespaces)和作用域(Scopes)讲座命名空间(Namespace)命名空间(Namespace)&#xff0c;是名称到对象的映射。命名空间提供了在项目中避免名字冲突的一种方法。命名空间是独立的&#xff0c;没有任何关系的&#xff0c;所以一个命名空间中不能有重名&#xff0c;…

getminimum_Java Calendar getMinimum()方法与示例

getminimumCalendar类的getMinimum()方法 (Calendar Class getMinimum() method) getMinimum() method is available in java.util package. getMinimum()方法在java.util包中可用。 getMinimum() method is used to get the minimum value of the given field(fi) of this Cal…

《Spark核心技术与高级应用》——3.2节构建Spark的开发环境

本节书摘来自华章社区《Spark核心技术与高级应用》一书中的第3章&#xff0c;第3.2节构建Spark的开发环境&#xff0c;作者于俊 向海 代其锋 马海平&#xff0c;更多章节内容可以访问云栖社区“华章社区”公众号查看 3.2 构建Spark的开发环境无论Windows或Linux操作系统&am…

python闭包怎么理解_Python 闭包的理解

Last Updated on 2019年10月15日Python中的闭包是一个比较模糊的概念&#xff0c;不太好理解&#xff0c;我最近的面试中也被问及&#xff0c;在一个单例模式的实现上&#xff0c;我用装饰器实现单例&#xff0c;然后面试官就问到了我对闭包的理解&#xff0c;回答的不太清楚。…

Java BufferedReader mark()方法与示例

BufferedReader类mark()方法 (BufferedReader Class mark() method) mark() method is available in java.io package. mark()方法在java.io包中可用。 mark() method is used to mark the current position in this stream and whenever we call reset() method so it will re…

《全球互联网金融商业模式:格局与发展》——第3章,第3节互联网保险公司...

本节书摘来自华章出版社《全球互联网金融商业模式&#xff1a;格局与发展》一书中的第3章&#xff0c;第3.3节互联网保险公司&#xff0c;作者廖理&#xff0c;更多章节内容可以访问云栖社区“华章计算机”公众号查看 3.3 互联网保险公司互联网思维贯穿整个保险创新发展过程&a…

webapi随机调用_BeetleX之webapi验证插件JWT集成

对于webapi服务应用很多时候需要制订访问限制&#xff0c;在前面的章节也讲述了组件如何制订控制器访问控制&#xff1b;但到了实际应用要自己去编写还是比较麻烦。为了让访问控制更方便组件实现基于JWT的控制器访问控制组件BeetleX.FastHttpApi.Jwt&#xff1b;通过这个组件可…

java bitset_Java BitSet nextClearBit()方法与示例

java bitsetBitSet类nextClearBit()方法 (BitSet Class nextClearBit() method) nextClearBit() method is available in java.util package. nextClearBit()方法在java.util包中可用。 nextClearBit() method is used to retrieve the index of the first bit that is set to …

《驯狮记——Mac OS X 10.8 Mountain Lion使用手册》——2.3 Dock

本节书摘来自异步社区《驯狮记——Mac OS X 10.8 Mountain Lion使用手册》一书中的第2章&#xff0c;第2.3节&#xff0c;作者&#xff1a;陈明 , 张铮 , 马玉龙著&#xff0c;更多章节内容可以访问云栖社区“异步社区”公众号查看 2.3 Dock 驯狮记——Mac OS X 10.8 Mountain…

mysql 嵌套if标签_对比Excel、MySQL、Python,分别讲述 “if函数” 的使用原理!

作者&#xff1a;黄伟呢本文转自&#xff1a;数据分析与统计学之美其实&#xff0c;不管是Excel、MySQL&#xff0c;还是Python&#xff0c;“if”条件判断都起着很重要的作用。今天这篇文章&#xff0c;就带着大家盘点一下&#xff0c;这三种语言如何分别使用 “if函数” 。if…

Java BigDecimal intValue()方法与示例

BigDecimal类的intValue()方法 (BigDecimal Class intValue() method) intValue() method is available in java.math package. intValue()方法在java.math包中可用。 intValue() method is used to convert a BigDecimal to an integer and when the converted BigDecimal val…

R语言数据挖掘

数据分析与决策技术丛书 R语言数据挖掘 Learning Data Mining with R &#xff3b;哈萨克斯坦&#xff3d;贝特麦克哈贝尔&#xff08;Bater Makhabel&#xff09; 著 李洪成 许金炜 段力辉 译 图书在版编目&#xff08;CIP&#xff09;数据 R语言数据挖掘 / &#xff08;哈…

linux adduser mysql_linux_adduser

新帐号建立当不加-D参数,useradd指令使用命令列来指定新帐号的设定值and使用系统上的预设值.新使用者帐号将产生一些系统档案&#xff0c;使用者目录建立&#xff0c;拷备起始档案等&#xff0c;这些均可以利用命令列选项指定。此版本为RedHatLinux提供&#xff0c;可帮每个新加…