java字节流到字符流的桥梁InputStreamReader,OutputStreamWriter

/*
    java中字符字节的转化使用
    @author:luowen
    @time:2013-10-24
*/

    import java.io.*;

    class ZijieZifu
    {
        public static void main(String[] args)throws IOException
        {
            //输入
            InputStream in = System.in;
            //输出
            OutputStream out = System.out;
            //定义输入流转字符流的桥梁
            InputStreamReader isr = null;
            //定义Reader缓冲区
            BufferedReader    bur = null;
            //定义输出字符流遍字节流桥梁
            OutputStreamWriter osw = null;
            //定义writer缓冲区
            BufferedWriter buw = null;

            try
            {
                isr = new InputStreamReader(in);
                bur = new BufferedReader(isr);
                osw = new OutputStreamWriter(out);
                buw = new BufferedWriter(osw);    

                String line = null;
                    while((line = bur.readLine()) != null)
                    {
                        if(line.equals("over"))
                            break;

                        buw.write(line.toUpperCase());
                        buw.newLine();
                        buw.flush();
                    }                

            }
            catch(IOException e)
            {
                System.out.println(e.toString());
            }
            finally
            {
                try
                {
                        bur.close();
                        buw.close();
                }
                catch(IOException e)
                {
                    System.out.println(e.toString());
                }    
            }

        }

    }
原文地址:https://www.cnblogs.com/luowen/p/3385526.html