gpt4 book ai didi

java - 无法将 Int 数组转换为 ASCII

转载 作者:行者123 更新时间:2023-12-01 21:54:13 25 4
gpt4 key购买 nike

说到重点了。我不知道是什么导致我的函数出错,但是当我想将 int 数组转换为 ASCII 字符时,我收到了一些错误,其中显示

java.lang.OutOfMemoryError: Failed to allocate a 51529974 byte allocation with 4194304 free bytes and 30MB

我认为我的函数不足以转换它。这是我的功能:

public static String[] DectoASCII(int[] resultXORDec,int jumKat) {
int length = jumKat;

String ASCIIfromDec[] = new String[jumKat];

for(int i=0;i<jumKat;i++) {
StringBuilder builder = new StringBuilder(length);
for (int j = length - 1; j >= 0; i--) {
builder.append((char) ((resultXORDec[j] >> (8 * i)) & 0xFF));
}
ASCIIfromDec[i]=builder.toString();
Log.d("ascifrom",ASCIIfromDec[i]);
}
return ASCIIfromDec;
}

}

请高手帮帮我。还有其他方法可以将 int (十进制)转换为 ASCII 码吗?谢谢..

最佳答案

嗯,我猜 j 索引在此循环中不会改变:

for (int j = length - 1; j >= 0; i--) {
builder.append((char) ((resultXORDec[j] >> (8 * i)) & 0xFF));
}

因此你有一个无限循环,因此builder变得越来越大。

关于java - 无法将 Int 数组转换为 ASCII,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34640296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com