What is the use of Bytearrayinputstream and Bytearrayoutputstream this two. Bytearrayinputstream can be called packing flow, Bytearrayoutputstream can be called intercept flow.
When a inputstream parameter is needed, proceed is byte[] what to do? How to pass the past satisfies the parameter. Do you want to write the array to a file and then get the path to InputStream. There is an easy way to wrap it in Bytearraystream.
Give the array as a parameter to the Bytearraystream constructor, and then let us wrap our array into a subclass of the inputstream below Bytearraystream, Then you can put the packaged bytearraystream to InputStream.
What does the Bytearrayoutputstream intercept stream mean. When the method parameter needs a outputstream, then takes the OutputStream output, what method can let him not output, the object wants the output content interception. Bytearraystream can do it.
When you new good bytearraystream, and then take this as a parameter passed in, call the Tobytearray method, get a byte[], converted to string for display, maybe he wrote Ah not according to the usual time of the incoming path, according to the path output, But read it on the Bytearraystream.
Api:
System: In the facilities provided by the system class, there are standard inputs, standard outputs, and error output streams;
Out: "standard" output stream. This stream is open and ready to accept output data.
PrintStream: Adds functionality to other output streams so that they can easily print various data-value representations.
PrintStream is also an output stream that can specify the output of the file, and the default systen.out output in the console. PrintStream can be inherited and manipulated before the println output under PrintStream is invoked.
Specify the output of the file, need System.setout (); API: Reassign the standard output stream.
1:system.out to the standard output stream, guess: output to the control Eclipse System console or CMD in this Visual window program, 2:new printstream ("D:/a.txt") by the specified path, output content