KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > j2ee > lib > RequiredFiles


1 /*
2 The contents of this file are subject to the terms of the Common Development
3 and Distribution License (the License). You may not use this file except in
4 compliance with the License.
5
6 You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7 or http://www.netbeans.org/cddl.txt.
8
9 When distributing Covered Code, include this CDDL Header Notice in each file
10 and include the License file at http://www.netbeans.org/cddl.txt.
11 If applicable, add the following below the CDDL Header, with the fields
12 enclosed by brackets [] replaced by your own identifying information:
13 "Portions Copyrighted [year] [name of copyright owner]"
14
15 The Original Software is NetBeans. The Initial Developer of the Original
16 Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17 Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * RequiredFiles.java
21  *
22  * Created on May 10, 2005, 11:23 AM
23  *
24  * To change this template, choose Tools | Options and locate the template under
25  * the Source Creation and Management node. Right-click the template and choose
26  * Open. You can then make changes to the template in the Source Editor.
27  */

28
29 package org.netbeans.test.j2ee.lib;
30
31 import java.io.BufferedReader JavaDoc;
32 import java.io.File JavaDoc;
33 import java.io.FileReader JavaDoc;
34 import java.io.IOException JavaDoc;
35 import java.util.HashSet JavaDoc;
36 import java.util.Set JavaDoc;
37
38 /**
39  *
40  * @author jungi
41  */

42 public class RequiredFiles {
43
44     private Set JavaDoc/*<String>*/ files;
45     
46     /**
47      * Creates a new instance of RequiredFiles from given <code>File</code>.
48      * @param f file containg the list of required files
49      * @throws IOException if some exception during reading <code>File f</code>
50      * occurs
51      */

52     public RequiredFiles(File JavaDoc f) throws IOException JavaDoc {
53         init(f);
54     }
55     
56     private void init(File JavaDoc f) throws IOException JavaDoc {
57         files = new HashSet JavaDoc();
58         BufferedReader JavaDoc r = new BufferedReader JavaDoc(new FileReader JavaDoc(f));
59         String JavaDoc s = null;
60         while ((s = r.readLine()) != null) {
61             if (s.startsWith("#")) {
62                 //skip comments
63
continue;
64             }
65             files.add(s.replace('/', File.separatorChar));
66         }
67     }
68     
69     /*
70      * Returns sorted list of required files (as String)
71      */

72     public Set JavaDoc/*<String>*/ getRequiredFiles() {
73         return new HashSet JavaDoc(files);
74     }
75 }
76
Popular Tags