String和Stream互转
一、方向:String--->Stream
这里,用ByteArrayInputStream(byte[] buf):
//code
String content = new String("ooxx");
InputStream is = new ByteArrayInputStream(content.getBytes());
二、方向:Stream--->String
这里用BufferedReader和InputStreamReader
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileLocation)));
String content="";
String line = br.readLine();
while(line!=null){
content += line+"\n";
line = br.readLine();
}
------
基础知识整理