【发布时间】:2014-07-21 14:07:39
【问题描述】:
我必须将字节数组转换为字符串。因此我使用这个函数:
public static String byteToString(byte[] bytes) {
String str = new String(bytes, Charset.forName("UTF8"));
return str;
}
问题是,它需要 API 9:
Call requires API level 9 (current min is 8): new java.lang.String
但我也想将我的应用程序提供给 API 8 用户。有没有可能或替代方案?
【问题讨论】:
-
哪个电话? forName?
-
@RobertHarvey 带有 Charset 参数的 String 构造函数