PipedWriter PipedWriter() in Java

PipedWriter(): This method is available in the java.io.PipedWriter class of Java.

Syntax:

java.io.PipedWriter.PipedWriter()

This method creates a piped writer that is not yet connected to a piped reader. It must be connected to a piped reader, either by the receiver or the sender, before being used.

Parameters: NA

Exceptions: NA

Approach

Java

import java.io.IOException;
import java.io.PipedWriter;

public class PipedWriterPipedWriter {
    public static void main(String[] args) throws IOException {

        PipedWriter pipedWriter = new PipedWriter();

        System.out.println(pipedWriter);
        pipedWriter.close();

    }
}

Output:

java.io.PipedWriter@26f0a63f


Some other methods of PipedWriter

close()This method closes this piped output stream and releases any system resources associated with this stream.

connect(PipedReader)This method connects this piped writer to a receiver.

flush()This method flushes this output stream and forces any buffered output characters to be written out.

PipedWriter(): This method creates a piped writer that is not yet connected to a piped reader.

PipedWriter(PipedReader)This method creates a piped writer connected to the specified piped reader.

write(int)This method writes the specified char to the piped output stream.

write(char[], int, int)This method writes len characters from the specified character array starting at offset off to this piped output stream.

No comments:

Post a Comment