码迷,mamicode.com
首页 > 其他好文 > 详细

字符流与字节流相互转换

时间:2016-01-06 21:37:54      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

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();
    }
}

 

字符流与字节流相互转换

标签:

原文地址:http://www.cnblogs.com/lovedaydream/p/5106752.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!