码迷,mamicode.com
首页 > 编程语言 > 详细

java:内存处理ByteArrayOutputStream,ByteArrayInputStream

时间:2017-07-09 19:38:13      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:cas   div   bytes   class   替换   tostring   输出   ase   依次   

 

              //用内存,将小写字母替换成大写字母
		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);                                    

  

java:内存处理ByteArrayOutputStream,ByteArrayInputStream

标签:cas   div   bytes   class   替换   tostring   输出   ase   依次   

原文地址:http://www.cnblogs.com/achengmu/p/7142410.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!