KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > tool > core > FileCopier


1 package org.apache.axis.tool.core;
2
3 import java.io.File JavaDoc;
4
5 import org.apache.tools.ant.Project;
6 import org.apache.tools.ant.taskdefs.Copy;
7 import org.apache.tools.ant.types.FileSet;
8
9 /*
10  * Copyright 2004,2005 The Apache Software Foundation.
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */

24
25 public class FileCopier extends Copy{
26     public FileCopier() {
27         this.setProject(new Project());
28         this.getProject().init();
29         this.setTaskType("copy");
30         this.setTaskName("copy-files");
31         this.setOwningTarget(new org.apache.tools.ant.Target());
32     }
33
34     public void copyFiles(File JavaDoc sourceFile,File JavaDoc destinationDirectory){
35
36         this.filesets.clear();
37
38         if (sourceFile.isFile())
39             this.setFile(sourceFile);
40         else {
41             FileSet fileset = new FileSet();
42             fileset.setDir(sourceFile);
43             fileset.setIncludes("*/**");
44             this.addFileset(fileset);
45         }
46         this.setTodir(destinationDirectory);
47         this.perform();
48     }
49
50
51 }
52
Popular Tags