您的位置:首页 > 其它

IO之字节数组输入输出流

2010-01-19 02:34 323 查看
package joeho.net.csdn.blog.io;

import java.io.*;
public class ByteArrayTest {

/**
* Method main
*
*
* @param args
*
*/
public static void main(String[] args) {
String strData = "afaerttwertrwert";
byte[] buf = strData.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(buf);
ByteArrayOutputStream out = new ByteArrayOutputStream();
upperTransform(in,out);
System.out.println(new String(out.toByteArray()));

//从键盘接受数据,用CTRL+Z退出
upperTransform(System.in,System.out);

}

/**
* Method upperTransform
*
*
* @param in
* @param out
*
*/
public static void upperTransform(InputStream in, OutputStream out) {
// TODO: Add your code here
int ch=0;
try{
while((ch=in.read())!=-1){
ch = Character.toUpperCase(ch);
out.write(ch);
}
}catch(Exception e){e.printStackTrace();}

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