首页 > 编程语言 > 详细

java:内存处理ByteArrayOutputStream,ByteArrayInputStream

时间:2017-07-09 18:58:27      阅读:178      评论:0      收藏:0      [点我收藏+]

 

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!