java 数组流

 

Example10_10.java

import java.io.*;
public class Example10_10 {
   public static void main(String args[]) {
      try {
         ByteArrayOutputStream outByte=new ByteArrayOutputStream();
         byte [] byteContent="mid-autumn festival".getBytes(); 
         outByte.write(byteContent); 
         ByteArrayInputStream inByte=new ByteArrayInputStream(outByte.toByteArray());
         byte backByte []=new byte[outByte.toByteArray().length];
         inByte.read(backByte);
         System.out.println(new String(backByte));
         CharArrayWriter outChar=new CharArrayWriter();
         char [] charContent="中秋快乐".toCharArray(); 
         outChar.write(charContent); 
         CharArrayReader inChar=new CharArrayReader(outChar.toCharArray());
         char backChar []=new char[outChar.toCharArray().length];
         inChar.read(backChar);
         System.out.println(new String(backChar));
      }
      catch(IOException exp){}
  }
}

 

posted @ 2016-10-23 20:08  我有一壶酒  阅读(231)  评论(0编辑  收藏  举报