KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > standalone > Main


1 /*
2  * This file is subject to the license found in LICENCE.TXT in the root directory of the project.
3  *
4  * #SNAPSHOT#
5  */

6 package standalone;
7
8 import java.util.Properties JavaDoc;
9
10 import org.apache.commons.lang.WordUtils;
11
12 /**
13  * TODO write javadoc
14  */

15 public class Main {
16     /**
17      * Returns the version of the project
18      * @return a string representation of the version, null if the version could not be retreived
19      */

20     public static String JavaDoc getVersion() {
21         Properties JavaDoc p = new Properties JavaDoc();
22         try {
23             p.load(Main.class.getResourceAsStream("/version.properties"));
24             String JavaDoc version = p.getProperty("version");
25             if (version != null) {
26                 return String.valueOf(Integer.parseInt(version));
27             }
28         } catch (Exception JavaDoc e) {
29             e.printStackTrace();
30         }
31         return null;
32     }
33     
34     /**
35      * Return the same string with all words capitalized.
36      * @param str the string conatining the words to capitalize
37      * @return null if the string was null, the string with all words capitalized otherwise
38      */

39     public static String JavaDoc capitalizeWords(String JavaDoc str) {
40         System.out.println(" [" + Main.class.getName() + "] capitalizing string \"" + str + "\" using " + WordUtils.class.getName());
41         return WordUtils.capitalizeFully(str);
42     }
43     public static void main(String JavaDoc[] args) {
44         String JavaDoc message="sentence to capitalize";
45         System.out.println("standard message : " + message);
46         System.out.println("capitalized message : " + capitalizeWords(message));
47     }
48 }
49
Popular Tags