59 |
/** |
/** |
60 |
* @author Jesse Rosenstock |
* @author Jesse Rosenstock |
61 |
* @since 1.4 |
* @since 1.4 |
62 |
|
* @status updated to 1.5 |
63 |
*/ |
*/ |
64 |
public abstract class Charset implements Comparable |
public abstract class Charset implements Comparable |
65 |
{ |
{ |
117 |
} |
} |
118 |
} |
} |
119 |
|
|
120 |
|
/** |
121 |
|
* Returns the system default charset. |
122 |
|
* |
123 |
|
* This may be set by the user or VM with the file.encoding |
124 |
|
* property. |
125 |
|
*/ |
126 |
|
public static Charset defaultCharset() |
127 |
|
{ |
128 |
|
String encoding; |
129 |
|
try |
130 |
|
{ |
131 |
|
encoding = System.getProperty("file.encoding"); |
132 |
|
} catch(SecurityException e) { |
133 |
|
encoding = "ISO-8859-1"; |
134 |
|
} catch(IllegalArgumentException e) { |
135 |
|
encoding = "ISO-8859-1"; |
136 |
|
} |
137 |
|
|
138 |
|
try |
139 |
|
{ |
140 |
|
return forName(encoding); |
141 |
|
} catch(UnsupportedCharsetException e) { |
142 |
|
} catch(IllegalCharsetNameException e) { |
143 |
|
} catch(IllegalArgumentException e) { |
144 |
|
} |
145 |
|
throw new IllegalStateException("Can't get default charset!"); |
146 |
|
} |
147 |
|
|
148 |
public static boolean isSupported (String charsetName) |
public static boolean isSupported (String charsetName) |
149 |
{ |
{ |
150 |
return charsetForName (charsetName) != null; |
return charsetForName (charsetName) != null; |