1 |
/* Charset.java -- |
/* Charset.java -- |
2 |
Copyright (C) 2002, 2004 Free Software Foundation, Inc. |
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
126 |
public static Charset defaultCharset() |
public static Charset defaultCharset() |
127 |
{ |
{ |
128 |
String encoding; |
String encoding; |
129 |
|
|
130 |
try |
try |
131 |
{ |
{ |
132 |
encoding = System.getProperty("file.encoding"); |
encoding = System.getProperty("file.encoding"); |
133 |
} catch(SecurityException e) { |
} |
134 |
|
catch(SecurityException e) |
135 |
|
{ |
136 |
|
// Use fallback. |
137 |
encoding = "ISO-8859-1"; |
encoding = "ISO-8859-1"; |
138 |
} catch(IllegalArgumentException e) { |
} |
139 |
|
catch(IllegalArgumentException e) |
140 |
|
{ |
141 |
|
// Use fallback. |
142 |
encoding = "ISO-8859-1"; |
encoding = "ISO-8859-1"; |
143 |
} |
} |
144 |
|
|
145 |
try |
try |
146 |
{ |
{ |
147 |
return forName(encoding); |
return forName(encoding); |
|
} catch(UnsupportedCharsetException e) { |
|
|
} catch(IllegalCharsetNameException e) { |
|
|
} catch(IllegalArgumentException e) { |
|
148 |
} |
} |
149 |
|
catch(UnsupportedCharsetException e) |
150 |
|
{ |
151 |
|
// Ignore. |
152 |
|
} |
153 |
|
catch(IllegalCharsetNameException e) |
154 |
|
{ |
155 |
|
// Ignore. |
156 |
|
} |
157 |
|
catch(IllegalArgumentException e) |
158 |
|
{ |
159 |
|
// Ignore. |
160 |
|
} |
161 |
|
|
162 |
throw new IllegalStateException("Can't get default charset!"); |
throw new IllegalStateException("Can't get default charset!"); |
163 |
} |
} |
164 |
|
|