1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.util; |
12 | |
|
13 | |
import java.io.ByteArrayOutputStream; |
14 | |
import java.io.OutputStreamWriter; |
15 | |
import java.lang.reflect.Method; |
16 | |
import java.nio.charset.Charset; |
17 | |
|
18 | 0 | public class CharSetUtils extends org.apache.commons.lang.CharSetUtils |
19 | |
{ |
20 | |
public static String defaultCharsetName() |
21 | |
{ |
22 | |
try |
23 | |
{ |
24 | 0 | if (SystemUtils.IS_JAVA_1_4) |
25 | |
{ |
26 | 0 | return new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding(); |
27 | |
} |
28 | |
else |
29 | |
{ |
30 | 0 | Class target = Charset.class; |
31 | 0 | Method defaultCharset = target.getMethod("defaultCharset", ArrayUtils.EMPTY_CLASS_ARRAY); |
32 | 0 | Charset cs = (Charset) defaultCharset.invoke(target, (Object[]) null); |
33 | 0 | return cs.name(); |
34 | |
} |
35 | |
} |
36 | 0 | catch (Exception ex) |
37 | |
{ |
38 | 0 | throw new Error(ex); |
39 | |
} |
40 | |
} |
41 | |
} |
42 | |
|
43 | |
|