小知识记录,方便自己查询

String 转 BufferedReader

String s = "需要转的内容";

// 1.要将字符串转成字节
byte[] by = s.getBytes();

// 2.构造一个字节输入流
InputStream is = new ByteArrayInputStream(by);

// 3.通过输入流构造一个字符流
InputStreamReader isr = new InputStreamReader(is);

// 4.通过字符流构造一个缓存流
BufferedReader bReader = new BufferedReader(isr);

// 合起来
byte[] by = s.getBytes();
InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(by));
BufferedReader bReader  = new BufferedReader(isr);

你可能感兴趣的:(工作笔记,MyDemo)