Java PipedOutputStream connect()方法與示例

PipedOutputStream類的connect()方法 (PipedOutputStream Class connect() method)

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

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

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

    當此PipedOutputStream先前未連接到任何其他PipedInputStream時,使用connect()方法使此PipedOutputStream連接到給定的PipedInputStream。

  • 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 or pipe not connected properly, or stream closed.

    IOException:當出現任何輸入/輸出錯誤或管道未正確連接或流關閉時,可能引發此異常。

Syntax:

句法:

    public void connect(PipedInputStream pis);

Parameter(s):

參數:

  • PipedInputStream pis – represents the piped input stream to connect to this piped output stream.

    PipedInputStream pis –表示連接到此管道輸出流的管道輸入流。

Return value:

返回值:

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

該方法的返回類型為void ,不返回任何內容。

Example:

例:

// Java program to demonstrate the example 
// of void connect(PipedInputStream pis) method of 
// PipedOutputStream
import java.io.*;
public class ConnectOfPOS {
public static void main(String[] args) throws Exception {
int val = 65;
try {
// Instantiates PipedInputStream and 
// PipedOutputStream
PipedInputStream pipe_in = new PipedInputStream();
PipedOutputStream pipe_out = new PipedOutputStream();
// By using connect() method is to
// connect this pipe_out to the given pipe_in
pipe_out.connect(pipe_in);
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 read() method is to read
// the integer and converted into int
char ch = (char) pipe_in.read();
System.out.println("pipe_in.read(): " + ch);
}
// By using close() method is to close
// the stream
pipe_in.close();
pipe_out.close();
} catch (Exception ex) {
System.out.println(ex.toString());
}
}
}

Output

輸出量

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

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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541955.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541955.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541955.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

[轉載] 中國象棋軟件-引擎實現(一)概述

2005年6月我系第二批科技小組的項目正式確定為實現一款中國象棋對弈軟件。基本功能包括人機對戰、網絡對戰。我負責開發人機對戰的引擎部分&#xff0c;也就是讓計算機下棋。經過了暑假整整兩個月的學習與實踐&#xff0c;我終于初步完成了程序&#xff0c;雖然電腦的下棋水平實…

Java FilePermission getActions()方法與示例

FilePermission類的getActions()方法 (FilePermission Class getActions() method) getActions() method is available in java.io package. getActions()方法在java.io包中可用。 getActions() method is used to check whether this FilePermission and the given object are…

字符與編碼(編碼轉換)

作為一名程序員&#xff0c;肯定有被亂碼困擾的時候&#xff0c;真到了百思不得其解的時候&#xff0c;就會覺得&#xff1a;英文程序員真幸福。但其實只要明白編碼之間的轉換規律&#xff0c;其實亂碼還是很好解決的。我們都知道字符串在保存和傳輸的時候需要先經過編碼成二進…

mysql 刷新二進制日志_使用binlog日志恢復MySQL數據庫刪除數據的方法

binlog日志簡介:binlog 就是binarylog&#xff0c;二進制日志文件&#xff0c;這個文件記錄了MySQL所有的DDL和DML(除了數據查詢語句)語句&#xff0c;以事件形式記錄&#xff0c;還包含語句所執行的消耗的時間。binlog日志包括兩類文件&#xff1a;1)二進制日志索引文件(文件名…

Java FileInputStream available()方法與示例

FileInputStream類的available()方法 (FileInputStream Class available() method) available() method is available in java.io package. available()方法在java.io包中可用。 available() method is used to return the number of bytes left that can be read from this Fi…

mysql 輸出參數 sql語句_MySQL: 詳細的sql語句

1添1.1【插入單行】insert [into] (列名) values (列值)例&#xff1a;insert into Strdents (姓名,性別,出生日期) values (開心朋朋,男,1980/6/15)1.2【將現有表數據添加到一個已有表】insert into (列名) select from 例&#xff1a;insert into tongxunlu (姓名,地址,電子郵…

執行git push出現Everything up-to-date

在github上git clone一個項目&#xff0c;在里面創建一個目錄&#xff0c;然后git push的時候&#xff0c;出現報錯"Everything up-to-date" 原因&#xff1a;1&#xff09;沒有git add .2&#xff09;沒有git commit -m "提交信息"如果上面兩個步驟都成功…

Java File類boolean delete()方法(帶示例)

文件類布爾型delete() (File Class boolean delete()) This method is available in package java.io.File.delete(). 軟件包java.io.File.delete()中提供了此方法。 This method is used to delete file or directory by using delete() method and this method is accessible…

Unity3D Adam Demo的學習與研究

1.簡述 這篇文章是對Adam各種相關資料了解后進行一些精簡的內容。如果你想仔細研究某個技術請跳轉至unity相關頁面。 Adam官方頁面: https://unity3d.com/cn/pages/adam 搬運視頻以及資源包網盤下載: http://pan.baidu.com/s/1jH6NF86 Adam這個demo由8個人的團隊耗時6個月(part…

Java File類boolean isFile()方法(帶示例)

File類boolean isFile() (File Class boolean isFile()) This method is available in package java.io.File.isFile(). 軟件包java.io.File.isFile()中提供了此方法。 This method is used to check whether the file is specified by filepath is a file or not. 此方法用于檢…

要加油!

現實中我容易佩服一個人。 一個頑強的女人&#xff0c;一個艱苦奮斗的男人..... 但是在網絡的世界里&#xff0c;我沒有佩服過幾個&#xff0c;但是不得不說的就是冰河。同樣的年齡人家做的事情和我們做的事情差距是多么的大&#xff0c;真的想想心里都是天壤之別。 比一比才知…

Java DataOutputStream writeInt()方法及示例

DataOutputStream類writeInt()方法 (DataOutputStream Class writeInt() method) writeInt() method is available in java.io package. writeInt()方法在java.io包中可用。 writeInt() method is used to write the given integer value to the basic DataOutputStream as 4 b…

python安卓自動化實現方法_uiautomator +python 實現安卓UI自動化

簡單實例注&#xff1a;安卓6.0以上的手機不會自動安裝app-uiautomator.apk和app-uiautomator-test.apk&#xff0c;需要手動安裝&#xff0c;否則報錯ioerror RPC server not starteduiautomator pythonHTMLTestRunner 安卓UI自動化實現#coding:utf-8from uiautomator importD…

ES6特性之:Spread操作符

Spread操作符(...)&#xff0c;也稱作展開操作符&#xff0c;作用是將可迭代的(Iterable)對象進行展開。 比如有2個數組&#xff0c;我們要將其中一個數組中所有元素插入到另一個數組中&#xff0c;通過Spread操作符&#xff0c;就可以這樣進行&#xff1a; var fruits ["…

Java類class isMemberClass()方法及示例

類的類isMemberClass()方法 (Class class isMemberClass() method) isMemberClass() method is available in java.lang package. isMemberClass()方法在java.lang包中可用。 isMemberClass() method is used to check whether the underlying class is a member class or not.…

velocity自定義函數_velocity基本語法和總結

一&#xff1a;基本語法&#xff1a;1、#set(#a "a")$a ##輸出語句時直接寫變量的名稱即可2、判斷語句&#xff1a;#if($a "a") ##判斷語句沒有括號&#xff0c;也是直接輸出$a3、數組&#xff1a;#set($arry [0..10])$foreach($i in $arry)$i ##換行#e…

docker-machine指定cpu個數

序 給本機的一個服務壓測&#xff0c;結果半天qps上不了萬&#xff0c;而且經常跑滿cpu&#xff0c;搞半天發現&#xff0c;docker里頭才1核1G內存。原來boot2docker默認給docker-machine分配1個cpu和1G內存。 修改配置 docker-machine create \--driver virtualbox \--virtual…

Java ClassLoader findResources()方法與示例

ClassLoader類findResources()方法 (ClassLoader Class findResources() method) findResources() method is available in java.lang package. findResources()方法在java.lang包中可用。 findResources() method is used to find all the resources with the given resource …

Java ByteArrayInputStream mark()方法與示例

ByteArrayInputStream類mark()方法 (ByteArrayInputStream Class mark() method) mark() method is available in java.util package. mark()方法在java.util包中可用。 mark() method is used to set the current mark position in the stream from where read or write can b…

java mediainfo.dll_MediaInfo庫的簡單使用

想到一個問題, 如何獲得一個圖像文件(比如jpg, bmp, png)的信息. 自己查查文件的格式, 寫一個解析, 應該不困難; 但是找了下現成的, 發現MediaInfo庫已經可以非常好的實現需要的功能了.MediaInfo可以在sourceforge上找到, 是一個解析視頻,音頻, 圖片等媒體文件的庫. 可以得到文…