• Tech Travel Hub is your one stop, ultimate tour guide to all things tech, travel, visas and digital nomads
  • Home
  • Blog
    • Technology
      • General Tech
      • Blogging
      • Java
    • Lifestyle
      • General Lifestyle
    • Travel
    • Educational
    • Business
  • About
  • Contact
Menu
  • Home
  • Blog
    • Technology
      • General Tech
      • Blogging
      • Java
    • Lifestyle
      • General Lifestyle
    • Travel
    • Educational
    • Business
  • About
  • Contact
View Blog
March 29, 2023March 29, 2023

PipedOutputStream in Java:

A PipedOutputStream is an OutputStream that is transmitting end of a communication channel through the pipe. It implements half of a Pipe. Any information we write to this automatically ends up as input (or the associated PipedInputStream) implements the piping concept).

The PipedOutputStream class represents half of a communication pipe; a PipedOutputStream
must be connected to a PipedOutputStream. When the two halves of a communication pipe are connected, data written to the PipedOutputStream can be read from the PipedInputStream.

Ads code goes here

The communication pipe formed by a PipedOutputStream and a PipedInputStream should be
used to communicate between threads. If both ends of a pipe are used by the same thread, the thread can hang.

Two threads can communicate by having one thread send the data through PipedInputStream and other thread read data through a PipedOutputStream. So A PipedOutputStream must be connected to a PipedInputStream, which may be specified when the PipedOutputStream is created or with the connect() method.

The constructor of PipedOutputStream takes the argument as PipedInputStream.It is used to designate the destination of our data for multithreading to connect it to a FileterOutputStream object to provide a user interface.

The class structure of PipedOutputStream is given as:

public class java.io.PipedOutputStream extends java.io.OutputStream{
//constructors
public PipedOutputStream();
//creates a PipedInputStream which is not yet connected to a PipedInputStream. It needs to be 
//connected to a PipedInputStream either by the receiver or the sender before being used.
public PipedOutputStream(PipedInputStream stm)throws IOException;
//creates a PipedInputStream which is connected to a PipedOutputStream stm.
//methods
public void close()throws IOException;
public void connect(PipedInputStream stm)throws IOException;
public void write(int b)throws IOException;
public void write(byte b[],int offSet,int length)throws IOException;
public synchronized void flush() throws IOException; // Overrides OutputStream
}
 

In addition, all methods may throw an IOException if an IO error occurs apart from their regular Exceptions.

The details of the methods are given as:

public PipedOutputStream();

public PipedOutputStream() constructor creates a PipedOutputStream that is not connected to a PipedInputStream. The created object must be connected to a PipedInputStream before
it can be used.

public PipedOutputStream(PipedInputStream stm);

public PipedOutputStream(PipedInputStream stm) constructor creates a PipedOutputStream that sends data to the given PipedInputStream.

Parameter
stm – The PipedInputStream to connect.

public void close();

public void close() method closes the stream and releases the system resources that are associated with it.

public void connect(PipedInputStream stm);

public void connect(PipedInputStream stm) method connects this PipedOutputStream object to the given PipedInputStream. If this PipedOutputStream or stm is already connected, an exception is thrown.

Parameter
stm – The PipedInputStream to connect.

public void write(int b);

public void write(int b) method writes a byte of output. The method passes the given value directly to the connected PipedInputStream.

Parameter
b – The value to write.

public void write(byte b[],int offSet,int length);

public void write(byte b[],int offSet,int length) method writes len bytes of output from the given array, starting at offset off. The method passes the given data to the connected PipedInputStream.

Parameter
b – An array of bytes to write to the stream.
off – An offset into the byte array.
len – The number of bytes to write.

public synchronized void flush();

public synchronized void flush() method flushes the stream, which tells the connected PipedInputStream to notify its readers to read any available data.

Apart from these PipedOutputStream class also has inherited methods from class- Object. They are as follows:

  • clone()
  • finalize()
  • hashCode()
  • notifyAll()
  • wait()
  • wait(long, int)
  • equals(Object)
  • getClass()
  • notify()
  • toString()
  • wait(long)

PipedOutputStream class also has inherited method from class- OutputStream. That is as follows:

  • write(byte[])

 

 

 

 
 

Post navigation

Previous post
Next post

Umer Umer

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Simplified Concept on What Is Interface In Java: Detailed Facts In 5 Minutes
  • What is Integration Testing?
  • What is GEB-Groover Browser Functional Testing?
  • What is GEB- Detailed Facts in Just 5 Minutes
  • What is Extreme Programming(XP) Practice?

Categories

  • Adventure
  • Agile Methodology
  • All world Tour
  • Android Development
  • Ansible
  • App
  • App Development
  • Artificial Intelligence
  • AWS
  • Bitcoin
  • BlockChain
  • Blogging
  • Box Packing
  • Business
  • business
  • Business Communication
  • buying guide
  • C
  • car
  • Care
  • Certification
  • Certification
  • Chatbot
  • cinema
  • Cloud Tech
  • Content Marketing
  • Corporate
  • covid-19
  • crucible
  • Cryptocurrency
  • Database
  • DevOps
  • DevOps
  • Digital Marketing
  • Drawing
  • Dress
  • Educational
  • Employment
  • Entertainment
  • Exceptions In Java
  • Fashion
  • Festivals
  • Finance
  • Fitness
  • Food
  • Game
  • Gift ideas
  • Groovy
  • Health
  • Health
  • home
  • home improvement
  • HR
  • IllegalThreadStateException in Java
  • India Tour
  • Instagram
  • Ios
  • ISO
  • Java
  • Javascript
  • job
  • Kids Section
  • Kitchen
  • Law
  • Life Style
  • Lifestyle
  • Lifestyle Home Improvement
  • Main Stories
  • Management
  • Mattress
  • Motorable
  • Movie
  • nursing
  • Pendrive
  • Perspective
  • Pet
  • Popular
  • Programming
  • Python
  • Relationships
  • Selenium
  • SEO
  • Skin
  • SOAPUI
  • Social Media
  • Social Media Marketing
  • Software
  • software development
  • Software Development Model
  • Software Engineering
  • Software Testing
  • Sports
  • Startup
  • T Robot
  • TDD
  • Tech
  • Tech News
  • Tech News
  • Technology
  • Tool
  • Tour Guide
  • Tour Guide
  • Travel
  • UFT
  • Uncategorized
  • USB Cable
  • VPN
  • Web Development
  • Wordpress
  • Yoga
  • Youtube

Tags

Instagram Instagram Marketing Marketing SEO Thoptv App

Categories

  • Tech
  • Travel
  • Visas
  • Digital Nomad
  • Tech
  • Travel
  • Visas
  • Digital Nomad

Publishing

If you would like to publish on our site, please email admin@techtravelhub.com

Quick Links

  • Home
  • Blog
    • Technology
      • General Tech
      • Blogging
      • Java
    • Lifestyle
      • General Lifestyle
    • Travel
    • Educational
    • Business
  • About
  • Contact
  • Home
  • Blog
    • Technology
      • General Tech
      • Blogging
      • Java
    • Lifestyle
      • General Lifestyle
    • Travel
    • Educational
    • Business
  • About
  • Contact

Contact

Tech Travel Hub LLC

Address:
8 The Green STE A
Dover
Delaware, 19901

Phone: +1 302 956 9948