您的位置:首页 > 编程语言 > Java开发

java:内存处理ByteArrayOutputStream,ByteArrayInputStream

2017-07-09 18:33 543 查看
//用内存,将小写字母替换成大写字母
String str = "helloworld,goodmorning";
ByteArrayOutputStream bos = null;
ByteArrayInputStream bis = null;
bis = new ByteArrayInputStream(str.getBytes());
bos = new ByteArrayOutputStream();
int temp = -1;
while( (temp = bis.read()) != -1 ) //依次读取内存
{
//接收字符
char c = (char) temp;
bos.write(Character.toUpperCase(c)); //输出
}
//取出内存中的内容
String newStr = bos.toString();
System.out.println(newStr);


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: