2019-05-31 Java learning diaries IO (other stream) & Properties

Memory output stream:

1. What is the memory output stream

The output stream can write data to the memory, to a memory as a buffer, then write can get all the data one time

2, use

Create an object: new ByteArrayOutputStream ()

Write Data: writer (int), writer (byte [])

Get Data: toByteArray ()

Memory output stream of horse face questions:

Define a file input stream, call read (byte [] b) method, the contents of the printed document a.txt (byte array size is limited to 5)

Printing Overview and characteristics of the stream:

1. What is the print stream

This can easily flow the object toString () result output, and automatically add line feed, and can use the auto-refresh mode

System.out is a PrintStream, the default output information to the console

2, use

Print: print (), println ()
automatically brush out: PrintWriter (OutputStream out, boolean autoFlush , String encoding)

Print object data stream only operation

Overview of the standard input and output streams and output statements:

1. What is the standard input and output streams

System.in the InputStream is, the standard input stream of data bytes can be read from the default keyboard

System.out PrintStream is, the standard output stream, the default may be output to the byte data and character Console

2, modifying the standard input and output streams

Modify the input stream: System.setIn (InputStream)

Review output stream: System.setOut (PrintStream)

 

Guess you like

Origin www.cnblogs.com/clqbolg/p/10962688.html