import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class TestByteArray {
public static void main(String[] args) throws Exception{
String s = "NI HAO BEIJING";
ByteArrayInputStream bis = null;
ByteArrayOutputStream bos = null;
bis = new ByteArrayInputStream(s.getBytes());
bos = new ByteArrayOutputStream();
int temp = 0;
while((temp=bis.read())!=-1){
char c = (char)temp;
bos.write(Character.toLowerCase(c));
}
System.out.println( bos.toString());
bis.close();
bos.close();
}
}
程序中的Character.toLowerCase(c)它的返回值是char类型但是bos.write()方法里面接收的是int类型的数据 为什么还可以这样写? |
|