标签 io stream 下的文章

一个装饰者模式的例子


处理流BufferedReader,同时也是个装饰者模式

import java.awt.Frame;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.Buffer;
import java.util.concurrent.FutureTask;
public class Test {
public static void main(String[] args) {
    FileReader fileReader=null;
    BufferedReader bufferedReader=null;
    BufferedWriter bufferedWriter=null;
    FileWriter fileWriter=null;
    
    try {
        fileReader=new FileReader("D:/char.txt");
        fileWriter=new FileWriter("D:/wu.txt");
        bufferedReader=new BufferedReader(fileReader);
        bufferedWriter=new BufferedWriter(fileWriter);
        while(true)
        {
            String mysString=bufferedReader.readLine();
            if(mysString==null){
                break;
            }
            bufferedWriter.write(mysString);
        
        }
        
            
        
    } catch (Exception e) {
        // TODO: handle exception
    }finally{
        
        try {
            fileReader.close();
            bufferedReader.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
    }
    
}
}

shijiebei 365bet manbetx 188bet xinshui caipiao 95zz tongbaoyule beplay 88bifa 18luck betway bwin hg0088 aomenjinshayulecheng ca88 shenbotaiyangcheng vwin w88 weide