-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharsetUtil.java
More file actions
51 lines (37 loc) · 1.02 KB
/
Copy pathCharsetUtil.java
File metadata and controls
51 lines (37 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.io.UnsupportedEncodingException;
/**
* CharsetUtil
* Feature:
*/
public class CharsetUtil {
final CharsetUtil self = this;
public static final String UTF_8 = "UTF-8";
/* Constructors */
/* Public Methods */
public static byte[] stringToData(String string, String charsetName) {
if (string != null) {
try {
return string.getBytes(charsetName);
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return null;
}
public static String dataToString(byte[] data, String charsetName) {
if (data != null) {
try {
return new String(data, charsetName);
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return null;
}
/* Properties */
/* Overrides */
/* Delegates */
/* Private Methods */
}