zoukankan      html  css  js  c++  java
  • 内存流

    ByteArrayOutputStream

    public class ByteArrayOutputStream

    extends OutputStream

    此类实现了一个输出流,其中的数据被写入一个 byte 数组。

    ByteArrayInputStream

    public class ByteArrayInputStream

    extends InputStream

    ByteArrayInputStream 包含一个内部缓冲区,该缓冲区包含从流中读取的字节。内部计数器跟踪 read 方法要提供的下一个字节。

    关闭 ByteArrayInputStream 无效。此类中的方法在关闭此流后仍可被调用,而不会产生任何 IOException

     

    实例:

    package com.erquam.ByteArray;

     

    import java.io.ByteArrayInputStream;

    import java.io.ByteArrayOutputStream;

     

    public class ByteArray {

     

     

    public static void main(String[] args) {

    String context "hello hehe !!!!!!";

    ByteArrayOutputStream byteOutput new ByteArrayOutputStream();  //内存输出流

    //将内容保存到内存中

    ByteArrayInputStream byteInput new ByteArrayInputStream(context.getBytes());

    int len 0;

    while ((len byteInput.read()) != -1) {

    char (char)len;

    byteOutput.write(Character.toUpperCase(c));  //小写转成大写

    }

    //以后要用到的重点语句

    String newStr byteOutput.toString();  //输出内存的内容

    System.out.println(newStr);

    }

    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    UNIX常用shell
    exit函数
    linux消息队列
    互斥量
    RCS版本控制
    linux samba
    UML建模
    linux syslog
    python基础-列表List及内置方法
    仿美团详情页与购物车源码-详情页
  • 原文地址:https://www.cnblogs.com/ubuntuvim/p/4796568.html
Copyright © 2011-2022 走看看