分類  >  編程 >

java ByteArrayInputStream跟ByteArrayOutputStream基本操作

tags:    時間:2014-05-04 18:39:17
java ByteArrayInputStream和ByteArrayOutputStream基本操作

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

程序中幾個函數的相關說明



推薦閱讀文章

Bookmark the permalink ,來源:互聯網