Java IO Learning (15) Print output flow detailed

Source: Internet
Author: User
Tags character set flush locale printf string format

PrintStream (print output stream) detailed

PrintStream Introduction

PrintStream is the print output stream, which inherits from Filteroutputstream.

PrintStream is used to decorate other output streams. It adds functionality to other output streams, enabling them to easily print various data-value representations.

Unlike other output streams, PrintStream never throws IOException; its resulting ioexception is captured by its own function and set to the wrong mark, and the user can return the error mark through CheckError (). To see if a ioexception is generated inside the printstream.

In addition, PrintStream provides automatic flush and character set setup capabilities. The so-called automatic flush, that is, the data written to PrintStream will immediately call the flush () function.

PrintStream Function List

* * Constructor///"Output flow out" as PrintStream output stream, will not automatically flush, and the default character set//so-called "automatic flush", that is, every time the print (), println (), write () function, will be called
Flush () function;//and "Do not automatically flush", we need to manually invoke the flush () interface.
PrintStream (OutputStream out)//"output stream out" as the PrintStream output stream, automatically flush, and takes the default character set.
PrintStream (OutputStream out, Boolean AutoFlush)//will "output stream out" as the PrintStream output stream, automatically flush, using the CharsetName character set. PrintStream (OutputStream out, Boolean autoflush, String charsetname)//create file corresponding FileOutputStream,
The FileOutputStream is then used as the output stream of the PrintStream, not automatically flush, with the default character set. PrintStream (file file)//create the file corresponding FileOutputStream, and then the FileOutputStream as the PrintStream output stream, not automatically flush,
Adopt CharsetName Character Set. PrintStream (file file, String charsetname)//create filename corresponding to the FileOutputStream, and then the FileOutputStream as the output stream of the PrintStream,
Do not automatically flush, using the default character set. PrintStream (String fileName)//create fileName corresponding to the FileOutputStream, and then the FileOutputStream as the PrintStream output stream, not automatically flush,
Adopt CharsetName Character Set. PrintStream (String fileName, String charsetname)//append "character C" to the PrintStream output stream printstream append (char c)// Appends "character sequences" to all characters from start (including) to end (not included) to the PrintStream output stream printstream append (charsequence charsequence, int start, int end) Append all characters of the character sequence to the PrintStream output stream printstream append (charsequence charsequence)//flush "PrintStream output stream buffer data" and check
Error Boolean CheckError ()//Turn off "PrintStream output stream" synchronized void close ()//flush "PrintStream output stream buffer data". Tream format (Locale l, string format, Object ... args)//(based on "default Locale value (Area properties)" For formatting Data printstream format (string form At, Object ... args)//write "float data f corresponding string" to "PrintStream output stream", print actually calls the Write function void print (float f)//Will "double data d corresponds to the word String "writes to the PrintStream output stream", print actually calls the Write function void print (double D)//writes "string data str" to the "PrintStream output stream".     Print actually calls the Write function synchronized void print (string str)//writes the object o corresponding string to the PrintStream output stream, and print actually calls the Write function void Print (Object o)//write "character C corresponding string" to "PrintStream output stream", PRint actually calls the Write function void print (char c)//writes "character array chars corresponding string" to the PrintStream output stream, and print actually calls the Write function void print (char[) Chars)//writes "Long data L string" to "PrintStream output stream", print actually calls the Write function void print (long L)//writes the string "int data i" to Printstre AM output stream, print actually calls the Write function void print (int i)//Writes the string "Boolean data B" to the PrintStream output stream, and print actually calls the Write function void PR Int (Boolean B)//"Data args" is formatted according to the "Locale Value (area property)" format and written to the PrintStream output stream printstream printf (Locale l, String form At, Object ... args)//format data args according to default locale value (area properties) and write to PrintStream output stream printstream printf (String format , Object ... args)//write "line break" to "PrintStream output stream", println actually calls the Write function void println ()//Writes the "string + newline character corresponding to float data" to "PRINTST"
Ream output stream, println actually calls the Write function void println (float f)//writes "string + newline character for int data" to "PrintStream output stream", println actually calls the Write function void println (int i)//writes "string + newline character of Long data" to "PrintStream output stream", println actually calls the Write function void println (long L)//Will object o to Expected string + newline character "write to" PrintStream outputStream, println actually calls the Write function void println (Object o)//writes "character array chars corresponding string + newline character" to the PrintStream output stream, println actually calls the Write function void println (char[] chars)//writes "string str+ newline character" to "PrintStream output stream", println actually calls the Write function synchronized void println (Str ing str)//write "character c corresponding string + newline character" to "PrintStream output stream", println actually call write function void println (char c)//write "string + newline character for double data" to In the PrintStream output stream, println actually calls the Write function void println (double D)//writes the string + newline character corresponding to the Boolean data to the PrintStream output stream. Println actually calls the Write function void println (Boolean B)//writes the data onebyte to the PrintStream output stream. Onebyte is an int type, but actually writes only one byte synchronized void write (int onebyte)//writes "Length bytes from offset in buffer" to the PrintStream output stream
In void Write (byte[] buffer, int offset, int length)

Related Article

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.