ByteArrayInputStream

来源:互联网 发布:multisim mac版破解 编辑:程序博客网 时间:2024/04/29 14:21

public class ByteArray {
 public static void main(String args[]){
  String str="HELLO DAQING";
   //字符串都是大写,将字符串全部转换为小写
  byte b[]=str.getBytes();
  ByteArrayInputStream in=new ByteArrayInputStream(b);
  ByteArrayOutputStream out=new ByteArrayOutputStream();
  //程序中现在要求将大写变为小写,只能一个字节字节的读数据
  int c=0;
  while((c=in.read())!=-1){
   int ch=(int)Character.toLowerCase((char)c);
   //向输入流中写
   out.write(ch);
   
  }
  b=out.toByteArray();
  System.out.println("内容为:"+new String(b));
 }
}

原创粉丝点击