java ByteArrayInputStream和ByteArrayOutputStream基本操作

时间:2014-05-04 00:30:12   收藏:0   阅读:469

bubuko.com,布布扣

import java.io.*;

public class ByteArrayDemo
{
	public static void main(String[] args)
	{
		String str="abcdefghijklmnopqrstuvwxyz";
		byte[] b=str.getBytes();
		ByteArrayInputStream in=new ByteArrayInputStream(b);
		ByteArrayOutputStream out=new ByteArrayOutputStream();
		
		try 
		{
			new ByteArrayDemo().transform(in, out);
			byte[] outb=out.toByteArray();
			System.out.println(new String(outb));
		} 
		catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void transform(InputStream in,OutputStream out) throws IOException
	{
		int c=0;
		while((c=in.read())!=-1)
		{
			out.write((int)Character.toUpperCase((char)c));
		}
	}
}
bubuko.com,布布扣

程序中几个函数的相关说明

bubuko.com,布布扣

bubuko.com,布布扣

java ByteArrayInputStream和ByteArrayOutputStream基本操作,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!