字符流与字节流相互转换
import java.io.*; class TransDemo { public static void main(String[] args)throws IOException { //字节流转字符流 InputStream in = System.in; InputStreamReader isr = new InputStreamReader(in); BufferedReader bufr = new BufferedReader(isr); //字符流转字节流 OutputStream out = System.out; OutputStreamWriter osw = new OutputStreamWriter(out); BufferedWriter bufw = new BufferedWriter(osw); String line = null; while((line=bufr.readLine())!=null){ if("over".equals(line)) break; //System.out.println(line); bufw.write(line); bufw.newLine(); } bufr.close(); } }