A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© 高阳 中级黑马   /  2013-1-2 00:48  /  1461 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

* 字符数组:
* CharArrayReader
* CharArrayWriter
*
* 字符串:
* StringReader
* StringWriter
*/
public class ByteArrayStreamDemo {
public static void main(String[] args) throws IOException {
  ByteArrayInputStream bis = new ByteArrayInputStream("abcde".getBytes());
  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  int num = 0;
  while ((num = bis.read()) != -1) {
   bos.write(num);
  }
  String str = bos.toString();
  System.out.println(str);
  // 释放资源 不需要释放,我们这次操作的数据就是在内存中转了一圈。
  // bos.close();
  // bis.close();
}
能yoga数组和字符串包装吗

评分

参与人数 1技术分 +1 收起 理由
冯海霞 + 1

查看全部评分

您需要登录后才可以回帖 登录 | 加入黑马