Write data to OutputStream via Filteroutputstream

Source: Internet
Author: User

The datainputstream corresponds to the DataOutputStream, which formats the basic data types and string objects and place them in a data "stream" so that the DataInputStream on any machine can read them properly. All methods begin with "Wirte", such as WriteByte (), Writefloat (), and so on.
If you want to make some real formatted output, such as output to the console, use PrintStream. It allows you to print out all the basic data types as well as string objects, and you can use a format that is easy to see. This is exactly the opposite of DataOutputStream, whose goal is to place those data in a data stream so that DataInputStream can easily reconstruct them. System.out static object is a printstream.
Two important methods within PrintStream are print () and println (). They have been overwritten to print out all data types. The difference between print () and println () is that the latter automatically adds a new row after the operation completes.
Bufferedoutputstream is a "modifier" that instructs the data stream to use buffering technology so that it does not have to physically write data to the stream every time. It should usually be applied to file processing and controller IO.
Table 10.4 Type of Filteroutputstream

Class

Function

Constructor Arguments

How to use it

Data-outputstream

Used in concert with DataInputStream can write primitives (int, char, long, etc.) to a stream in a portabl E fashion.

OutputStream

Contains full interface to allow your to write primitive types.

PrintStream

For producing formatted output. While DataOutputStream handles the storage of data, PrintStream handles display.

OutputStream, with optional Boolean indicating that's the buffer is flushed with every newline.

Should is the "final" wrapping for your outputstream object. You ' ll probably the use of this a lot.

Buffered-outputstream

Use the Prevent a physical write every time you send a piece of data. "Re saying" use a buffer. Can call flush () to flush the buffer.

OutputStream, with optional buffer size.

This doesn ' t provide the interface per se, just a requirement that a-buffer is used. Attach an interface object.


Class feature builder parameters/how to use

DataOutputStream is used in conjunction with DataInputStream to write basic data types (Int,char,long, etc.) to a data stream in a convenient form outputstream/contains the full interface so we can write to the basic data type
PrintStream is used to produce formatted output. DataOutputStream controls the "storage" of the data, while PrintStream controls the "display" OutputStream, optionally a Boolean parameter indicating whether the buffer is refreshed with each new row/for its own OutputStream object and should be "Final" to seal it. You might want to use it a lot.
Bufferedoutputstream uses it to avoid physical writing every time the data is emitted, requiring it to "look in the buffer first". You can invoke flush () to refresh the buffer outputstream, the optional buffer size/itself does not provide an interface, just emit the requirement of using a buffer. Requires the same interface object to be connected together.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.