Pipe
Stay organized with collections
Save and categorize content based on your preferences.
A pair of channels that implements a unidirectional pipe.
A pipe consists of a pair of channels: A writable sink
channel and a readable source
channel. Once some bytes are written to the sink channel they can be read
from source channel in exactlyAthe order in which they were written.
Whether or not a thread writing bytes to a pipe will block until another
thread reads those bytes, or some previously-written bytes, from the pipe is
system-dependent and therefore unspecified. Many pipe implementations will
buffer up to a certain number of bytes between the sink and source channels,
but such buffering should not be assumed.
Protected Constructor Summary
|
Pipe()
Initializes a new instance of this class.
|
Inherited Method Summary
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals( Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(long timeout, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long timeout)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
Protected Constructors
protected
Pipe
()
Initializes a new instance of this class.
Public Methods
public
static
Pipe
open
()
Opens a pipe.
The new pipe is created by invoking the openPipe
method of the
system-wide default SelectorProvider
object.
Returns this pipe's sink channel.
Returns this pipe's source channel.
Returns
- This pipe's source channel
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eA \u003ccode\u003ePipe\u003c/code\u003e in Java NIO is a unidirectional communication channel consisting of a sink for writing and a source for reading data.\u003c/p\u003e\n"],["\u003cp\u003eData written to the sink channel can be read from the source channel in the order it was written.\u003c/p\u003e\n"],["\u003cp\u003eBlocking behavior during writes depends on the system and whether the buffer between the channels is full.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ePipe\u003c/code\u003e provides methods to open a pipe and access its sink and source channels for data transfer.\u003c/p\u003e\n"],["\u003cp\u003eIt's worth noting that buffering between the sink and source channels is implementation-specific and not guaranteed.\u003c/p\u003e\n"]]],[],null,["public abstract class **Pipe** extends [Object](../../../../reference/java/lang/Object.html) \nA pair of channels that implements a unidirectional pipe.\n\nA pipe consists of a pair of channels: A writable [sink](../../../../reference/java/nio/channels/Pipe.SinkChannel.html) channel and a readable [source](../../../../reference/java/nio/channels/Pipe.SourceChannel.html)\nchannel. Once some bytes are written to the sink channel they can be read\nfrom source channel in exactlyAthe order in which they were written.\n\nWhether or not a thread writing bytes to a pipe will block until another\nthread reads those bytes, or some previously-written bytes, from the pipe is\nsystem-dependent and therefore unspecified. Many pipe implementations will\nbuffer up to a certain number of bytes between the sink and source channels,\nbut such buffering should not be assumed.\n\n\u003cbr /\u003e\n\nNested Class Summary\n\n|-------|---|---|---------------------------------------------------------------------------------------------------------|\n| class | [Pipe.SinkChannel](../../../../reference/java/nio/channels/Pipe.SinkChannel.html) || A channel representing the writable end of a [Pipe](../../../../reference/java/nio/channels/Pipe.html). |\n| class | [Pipe.SourceChannel](../../../../reference/java/nio/channels/Pipe.SourceChannel.html) || A channel representing the readable end of a [Pipe](../../../../reference/java/nio/channels/Pipe.html). |\n\nProtected Constructor Summary\n\n|---|--------------------------------------------------------------------------------------------------------------|\n| | [Pipe](../../../../reference/java/nio/channels/Pipe.html#Pipe())() Initializes a new instance of this class. |\n\nPublic Method Summary\n\n|------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|\n| static [Pipe](../../../../reference/java/nio/channels/Pipe.html) | [open](../../../../reference/java/nio/channels/Pipe.html#open())() Opens a pipe. |\n| abstract [Pipe.SinkChannel](../../../../reference/java/nio/channels/Pipe.SinkChannel.html) | [sink](../../../../reference/java/nio/channels/Pipe.html#sink())() Returns this pipe's sink channel. |\n| abstract [Pipe.SourceChannel](../../../../reference/java/nio/channels/Pipe.SourceChannel.html) | [source](../../../../reference/java/nio/channels/Pipe.html#source())() Returns this pipe's source channel. |\n\nInherited Method Summary \nFrom class [java.lang.Object](../../../../reference/java/lang/Object.html) \n\n|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Object](../../../../reference/java/lang/Object.html) | [clone](../../../../reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |\n| boolean | [equals](../../../../reference/java/lang/Object.html#equals(java.lang.Object))([Object](../../../../reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |\n| void | [finalize](../../../../reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |\n| final [Class](../../../../reference/java/lang/Class.html)\\\u003c?\\\u003e | [getClass](../../../../reference/java/lang/Object.html#getClass())() Returns the unique instance of [Class](../../../../reference/java/lang/Class.html) that represents this object's class. |\n| int | [hashCode](../../../../reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |\n| final void | [notify](../../../../reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| final void | [notifyAll](../../../../reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| [String](../../../../reference/java/lang/String.html) | [toString](../../../../reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |\n\nProtected Constructors \n\nprotected\n**Pipe**\n() \nInitializes a new instance of this class.\n\nPublic Methods \n\npublic static [Pipe](../../../../reference/java/nio/channels/Pipe.html)\n**open**\n() \nOpens a pipe.\n\nThe new pipe is created by invoking the [openPipe](../../../../reference/java/nio/channels/spi/SelectorProvider.html#openPipe()) method of the\nsystem-wide default [SelectorProvider](../../../../reference/java/nio/channels/spi/SelectorProvider.html)\nobject.\n\n\u003cbr /\u003e\n\nReturns\n\n- A new pipe \n\nThrows\n\n| [IOException](../../../../reference/java/io/IOException.html) | If an I/O error occurs |\n|---------------------------------------------------------------|------------------------|\n\npublic abstract [Pipe.SinkChannel](../../../../reference/java/nio/channels/Pipe.SinkChannel.html)\n**sink**\n() \nReturns this pipe's sink channel. \n\nReturns\n\n- This pipe's sink channel \n\npublic abstract [Pipe.SourceChannel](../../../../reference/java/nio/channels/Pipe.SourceChannel.html)\n**source**\n() \nReturns this pipe's source channel. \n\nReturns\n\n- This pipe's source channel"]]