Java.io.ByteArrayOutputStream.reset() 方法 Java.io.ByteArrayInputStream.skip() 方法 Java.io.ByteArrayOutputStream.close() 方法 Java.io.ByteArrayOutputStream.reset() 方法 package com.codingdict; import java.io.ByteArrayOutputStream; import java.io.IOException; public class ByteArrayOutputStreamDemo { public static void main(String[] args) throws IOException { ByteArrayOutputStream baos = null; try { String str = ""; // create new ByteArrayOutputStream baos = new ByteArrayOutputStream(); // writing byte to output stream baos.write(75); // output stream to string str = baos.toString(); System.out.println("Before Resetting : "+str); // reset() method invocation baos.reset(); // writing byte to output stream baos.write(65); // output stream to string() str = baos.toString(); System.out.println("After Resetting : "+ str); } catch(Exception e) { // if I/O error occurs e.printStackTrace(); } finally { if(baos!=null) baos.close(); } } } Java.io.ByteArrayInputStream.skip() 方法 Java.io.ByteArrayOutputStream.close() 方法