KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > w3c > flute > util > Encoding


1 /*
2  * Copyright (c) 1999 World Wide Web Consortium
3  * (Massachusetts Institute of Technology, Institut National de Recherche
4  * en Informatique et en Automatique, Keio University).
5  * All Rights Reserved. http://www.w3.org/Consortium/Legal/
6  *
7  * $Id: Encoding.java,v 1.1.1.1 2006/04/23 14:51:57 taqua Exp $
8  */

9 package org.w3c.flute.util;
10
11 import java.io.InputStream JavaDoc;
12 import java.net.URL JavaDoc;
13 import java.util.Properties JavaDoc;
14
15 /**
16  * @version $Revision: 1.1.1.1 $
17  * @author Philippe Le Hegaret
18  */

19 public class Encoding {
20     private Encoding() {}
21
22     /**
23      * Converts the format encoding information into Java encoding information.
24      */

25     public static String JavaDoc getJavaEncoding(String JavaDoc encoding) {
26     String JavaDoc _result = encodings.getProperty(encoding);
27     if (_result == null) {
28         return encoding;
29     }
30     return _result;
31     }
32
33     static Properties JavaDoc encodings;
34
35     static {
36     encodings = new Properties JavaDoc();
37     
38     try {
39             URL JavaDoc url = Encoding.class.getResource("encoding.properties");
40             InputStream JavaDoc f = url.openStream();
41             encodings.load(f);
42             f.close();
43         } catch (Exception JavaDoc e) {
44             System.err.println(Encoding.class
45                                + ": couldn't load encoding properties ");
46             e.printStackTrace();
47     }
48     }
49 }
50
Popular Tags