Look directly at the code:
PackageCn.itcast.io.p6.bytestream;ImportJava.io.ByteArrayInputStream;ImportJava.io.ByteArrayOutputStream;Importjava.io.IOException; Public classBytearraystreamdemo {/** * @paramargs *@throwsIOException * Features * 1. Memory operation Flow * 2. Do not operate the underlying resource, do not invoke the underlying resource of the operating system, manipulate the data in memory, the memory stream does not need to close * 3. After you close the stream you can also use the * This example: memory operation Flow Complete A program that converts a case to a lowercase letter:*/ Public Static voidMain (string[] args) {String str= "HELLO world!"; Bytearrayinputstream bis=NewBytearrayinputstream (Str.getbytes ());//entering content into memoryBytearrayoutputstream BOS =NewBytearrayoutputstream ();//to output the in-memory data intCH = 0; Bis.skip (2);//Skip Two bytesSystem.out.println (Bis.available ());//returns the number of bytes remaining in this input stream read (or skipped) while((Ch=bis.read ())!=-1) {bos.write (character.tolowercase (CH));//Convert size characters to lowercase} System.out.println (Bos.tostring ()); }}
Output: Since two bytes are skipped, HELLO world! has a total of 12 bytes, then the remaining 10 bytes.
10
Llo world!