Java如何把字符串转化为输入流

try{
InputStream myIn=new ByteArrayInputStream(txt.getBytes());
//将System.in转化为面向字符的流
InputStreamReader ir = new InputStreamReader(myIn);

in = new BufferedReader(ir);//为输入流提供缓冲区

while ((s = in.readLine()) != "bye")
System.out.println("Read: " + s);

}
catch(IOException e)
{System.out.println("Error! ");}
}

你可能感兴趣的:(字符集)