java 有没有直接把ascii数组转字符串的方法?循环转的就不要回我了。转换例子如下:
答案:2 悬赏:40 手机版
解决时间 2021-03-02 00:06
- 提问者网友:最美的风景
- 2021-03-01 03:50
[32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 50, 48, 49, 52, 49, 50, 50, 52, 50, 48, 48, 48, 49, 52, 48, 48, 48, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 67, 65, 75, 45, 48, 49, 65, 76, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 50, 48, 49, 52, 49, 50, 50, 52, 50, 48, 48, 48, 49, 52, 56, 55, 50, 48, 48, 32, 32, 48, 48, 48, 48, 48, 48, 48, 48, 72, 65, 76, 65, 82, 77, 32, 84, 69, 88, 84, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]
最佳答案
- 五星知识达人网友:掌灯师
- 2021-03-01 04:37
@Test
public void test(){
char[] testChar = {32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 50, 48, 49, 52, 49, 50, 50, 52, 50, 48, 48, 48, 49, 52, 48, 48, 48, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 67, 65, 75, 45, 48, 49, 65, 76, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 50, 48, 49, 52, 49, 50, 50, 52, 50, 48, 48, 48, 49, 52, 56, 55, 50, 48, 48, 32, 32, 48, 48, 48, 48, 48, 48, 48, 48, 72, 65, 76, 65, 82, 77, 32, 84, 69, 88, 84, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32};
String testStr = String.valueOf(testChar);
System.out.println("-->" + testStr + "<--");
}
public void test(){
char[] testChar = {32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 50, 48, 49, 52, 49, 50, 50, 52, 50, 48, 48, 48, 49, 52, 48, 48, 48, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 67, 65, 75, 45, 48, 49, 65, 76, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 50, 48, 49, 52, 49, 50, 50, 52, 50, 48, 48, 48, 49, 52, 56, 55, 50, 48, 48, 32, 32, 48, 48, 48, 48, 48, 48, 48, 48, 72, 65, 76, 65, 82, 77, 32, 84, 69, 88, 84, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32};
String testStr = String.valueOf(testChar);
System.out.println("-->" + testStr + "<--");
}
全部回答
- 1楼网友:独行浪子会拥风
- 2021-03-01 04:49
new string(bytearray);
string(byte[] bytes)
constructs a new string by decoding the specified array of bytes using the platform's default charset.
换成这个构造函数:
string(byte[] bytes, string charsetname)
constructs a new string by decoding the specified array of bytes using the specified charset.
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯