内存流操作

String str = "HELLOWORLD";
ByteArrayInputStream bis = new ByteArrayInputStream(str.getBytes());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int temp = 0;
while((temp = bis.read()) != -1){
char c = (char) temp;
bos.write(Character.toLowerCase(c));
}
String newStr = bos.toString();
try{
bis.close();
bos.close();

}catch(Exception e){
e.printStackTrace();
}
System.out.println(newStr);
}

你可能感兴趣的:(内存流操作)