Pipe
public
abstract
class
Pipe
extends Object
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 the source channel in exactly the 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.
Summary
Nested classes |
class |
Pipe.SinkChannel
A channel representing the writable end of a Pipe .
|
class |
Pipe.SourceChannel
A channel representing the readable end of a Pipe .
|
Protected constructors |
Pipe()
Initializes a new instance of this class.
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
Protected constructors
Pipe
protected Pipe ()
Initializes a new instance of this class.
Public methods
open
public static Pipe open ()
Opens a pipe.
The new pipe is created by invoking the openPipe
method of the
system-wide default SelectorProvider
object.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-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 2025-02-10 UTC."],[],[],null,["# Pipe\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Nested Classes](#nestedclasses) \\| [Protected Ctors](#proctors) \\| [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nPipe\n====\n\n\n`\npublic\n\n\nabstract\nclass\nPipe\n`\n\n\n`\n\nextends `[Object](/reference/java/lang/Object)`\n\n\n`\n\n`\n\n\n`\n\n|---|------------------------|\n| [java.lang.Object](/reference/java/lang/Object) ||\n| ↳ | java.nio.channels.Pipe |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\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) channel and a readable [source](/reference/java/nio/channels/Pipe.SourceChannel)\nchannel. Once some bytes are written to the sink channel they can be read\nfrom the source channel in exactly the 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\nSummary\n-------\n\n| ### Nested classes ||\n|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` class` | [Pipe.SinkChannel](/reference/java/nio/channels/Pipe.SinkChannel) A channel representing the writable end of a [Pipe](/reference/java/nio/channels/Pipe). |\n| ` class` | [Pipe.SourceChannel](/reference/java/nio/channels/Pipe.SourceChannel) A channel representing the readable end of a [Pipe](/reference/java/nio/channels/Pipe). |\n\n| ### Protected constructors ||\n|----------------------------------------------------------------------------------------------------|---|\n| ` `[Pipe](/reference/java/nio/channels/Pipe#Pipe())`() ` Initializes a new instance of this class. |\n\n| ### Public methods ||\n|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|\n| ` static `[Pipe](/reference/java/nio/channels/Pipe) | ` `[open](/reference/java/nio/channels/Pipe#open())`() ` Opens a pipe. |\n| ` abstract `[Pipe.SinkChannel](/reference/java/nio/channels/Pipe.SinkChannel) | ` `[sink](/reference/java/nio/channels/Pipe#sink())`() ` Returns this pipe's sink channel. |\n| ` abstract `[Pipe.SourceChannel](/reference/java/nio/channels/Pipe.SourceChannel) | ` `[source](/reference/java/nio/channels/Pipe#source())`() ` Returns this pipe's source channel. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` `[java.lang.Object](/reference/java/lang/Object)` ` |---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](/reference/java/lang/Object) | ` `[clone](/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object. | | ` boolean` | ` `[equals](/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](/reference/java/lang/Object)` obj) ` Indicates whether some other object is \"equal to\" this one. | | ` void` | ` `[finalize](/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final `[Class](/reference/java/lang/Class)`\u003c?\u003e` | ` `[getClass](/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this `Object`. | | ` int` | ` `[hashCode](/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object. | | ` final void` | ` `[notify](/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` `[notifyAll](/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor. | | ` `[String](/reference/java/lang/String) | ` `[toString](/reference/java/lang/Object#toString())`() ` Returns a string representation of the object. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||\n\nProtected constructors\n----------------------\n\n### Pipe\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\nprotected Pipe ()\n```\n\nInitializes a new instance of this class.\n\n\u003cbr /\u003e\n\nPublic methods\n--------------\n\n### open\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static Pipe open ()\n```\n\nOpens a pipe.\n\nThe new pipe is created by invoking the [openPipe](/reference/java/nio/channels/spi/SelectorProvider#openPipe()) method of the\nsystem-wide default [SelectorProvider](/reference/java/nio/channels/spi/SelectorProvider)\nobject.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------------------------------------------|-------------------|\n| [Pipe](/reference/java/nio/channels/Pipe) | A new pipe \u003cbr /\u003e |\n\n| Throws ||\n|-----------------------------------------------|------------------------|\n| [IOException](/reference/java/io/IOException) | If an I/O error occurs |\n\n### sink\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Pipe.SinkChannel sink ()\n```\n\nReturns this pipe's sink channel.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------------------------------------------------------------------|---------------------------------|\n| [Pipe.SinkChannel](/reference/java/nio/channels/Pipe.SinkChannel) | This pipe's sink channel \u003cbr /\u003e |\n\n### source\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Pipe.SourceChannel source ()\n```\n\nReturns this pipe's source channel.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------------------------------------------------------------------|-----------------------------------|\n| [Pipe.SourceChannel](/reference/java/nio/channels/Pipe.SourceChannel) | This pipe's source channel \u003cbr /\u003e |"]]