01: /*
02: * This file is part of DrFTPD, Distributed FTP Daemon.
03: *
04: * DrFTPD is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * DrFTPD is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with DrFTPD; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package net.sf.drftpd.util;
19:
20: import java.io.BufferedReader;
21: import java.io.File;
22: import java.io.FileReader;
23: import java.io.IOException;
24:
25: /**
26: * @author mog
27: * @version $Id: PropertyBuilder.java 1562 2007-01-05 12:37:07Z zubov $
28: */
29: public class PropertyBuilder {
30: private File _baseFile;
31: private int _prefixLength;
32:
33: public PropertyBuilder(File file) {
34: _baseFile = file;
35: _prefixLength = file.getPath().length() + 1;
36: }
37:
38: public static void main(String[] args) throws IOException {
39: PropertyBuilder pb = new PropertyBuilder(new File(args[0]));
40: pb.findAndReadFiles();
41: }
42:
43: public void findAndReadFiles() throws IOException {
44: findAndReadFiles(_baseFile);
45: }
46:
47: private void findAndReadFiles(File file) throws IOException {
48: File[] files = file.listFiles();
49:
50: for (int i = 0; i < files.length; i++) {
51: File file2 = files[i];
52:
53: if (file2.isDirectory()) {
54: findAndReadFiles(file2);
55: } else if (file2.getName().endsWith(".properties")) {
56: String classname = file2.getPath().substring(
57: _prefixLength);
58: classname = classname.replaceAll("\\.properties$", "");
59: classname = classname.replace(File.separatorChar, '.');
60:
61: BufferedReader in = null;
62: try {
63: in = new BufferedReader(new FileReader(file2));
64: System.out.println("## START: " + classname);
65:
66: String line;
67:
68: while ((line = in.readLine()) != null) {
69: if (line.trim().equals("")
70: || line.startsWith("#")) {
71: System.out.println(line);
72:
73: continue;
74: }
75:
76: System.out.println(classname + "." + line);
77: }
78: } finally {
79: if (in != null) {
80: in.close();
81: }
82: }
83: }
84: }
85: }
86: }
|