01 
02 /*
03  *  JavaDoq 1.0 - DOCUment JAVA In Source
04  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.javadoq.com>
05  *  
06  *  This program is free software: you can redistribute it and/or modify
07  *  it under the terms of the GNU Affero General Public License as published by
08  *  the Free Software Foundation, either version 3 of the License, or
09  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Affero General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU Affero General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 package com.javadoq.html;
21 
22 import java.io.BufferedReader;
23 import java.io.File;
24 import java.io.FileNotFoundException;
25 import java.io.FileReader;
26 import java.io.IOException;
27 
28 import com.javadoq.JavaDoq;
29 
30 /**
31  * <p>A transformer that simply copies a file.</p>
32  * 
33  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.javadoq.com" target="_blank">http://www.javadoq.com</a>
34  */
35 public final class DoqCopy extends Doq
36 {
37     /**
38      * <p>Constructs a {@link DoqCopy} transformer copying a file.</p>
39      * @param jdoq A {@link JavaDoq} environment.
40      * @param path The relative path to the source file and the target file.
41      * @since 1.0
42      */
43     public DoqCopy(JavaDoq jdoq, String path) {
44         super(jdoq.dst + File.separator + path);
45         try {
46             BufferedReader reader = new BufferedReader(
47                     new FileReader(jdoq.src + File.separator + path)
48             );
49             String line = null;
50             while ((line = reader.readLine()) != null) {
51                 writeLine(line);
52             }
53         } catch (FileNotFoundException e) {
54         } catch (IOException e) {
55             throw new RuntimeException(e);
56         }
57     }
58 }