KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > util > TomcatServiceXMLPasswordReplace


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13  
14 package org.ejbca.util;
15
16 import java.io.BufferedReader JavaDoc;
17 import java.io.FileReader JavaDoc;
18 import java.io.FileWriter JavaDoc;
19
20
21 /**
22  * DOCUMENT ME!
23  *
24  * @version $Id: TomcatServiceXMLPasswordReplace.java,v 1.1 2006/01/17 20:32:19 anatom Exp $
25  */

26 public class TomcatServiceXMLPasswordReplace {
27     /**
28      * Creates a new instance of TomcatServiceXMLPasswordReplace
29      */

30     public TomcatServiceXMLPasswordReplace() {
31     }
32
33     /**
34      * DOCUMENT ME!
35      *
36      * @param args DOCUMENT ME!
37      */

38     public static void main(String JavaDoc[] args) {
39         try {
40             // Check number of parameter.
41
if (args.length != 3) {
42                 System.out.println(
43                     "Required parameters : <tomcatservice.xml infile> <tomcatservice.xml outfile> <replacementpassword>");
44                 System.exit(0);
45             }
46
47             BufferedReader JavaDoc br = new BufferedReader JavaDoc(new FileReader JavaDoc(args[0]));
48             FileWriter JavaDoc fwr = new FileWriter JavaDoc(args[1]);
49             String JavaDoc line = null;
50
51             while ((line = br.readLine()) != null) {
52                 fwr.write(line.replaceAll("foo123", args[2]) + "\n");
53             }
54
55             br.close();
56             fwr.close();
57         } catch (Exception JavaDoc e) {
58             e.printStackTrace();
59         }
60     }
61
62     // main
63
}
64
65
66 // TomcatServiceXMLPasswordReplace
67
Popular Tags