字节数组流
- 判断字符串中字母的个数
- ByteArrayInputStream
- ByteArrayOutputStream
- 基于内存,无需关闭close
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
/**
* 字节数组流
* 判断字符串中字母的个数
* ByteArrayInputStream
* ByteArrayOutputStream
* 基于内存,无需关闭close
* @author wuzl
*
*/
public class test10 {
public static void byteString() {
String str = "hgcuwgeu978799wfAADGHTRihiufhwe@$%^$%&";
ByteArrayInputStream in = new ByteArrayInputStream(str.getBytes());
ByteArrayOutputStream out = new ByteArrayOutputStream();
int len = -1;
while ((len = in.read()) != -1) {
if ((len > 'a' && len < 'z') || (len > 'A' && len < 'Z')) {
out.write(len);
}
}
System.out.println(out.toString().length());
}
public static void main(String[] args) {
// TODO Auto-generated method stub
byteString();
}
}