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));
}
}
ByteArrayInputStream

最新推荐文章于 2025-06-27 08:01:05 发布
