我通过 REST 服务发送一个字节数组。它作为字符串接收。这是它的摘录。带有开始和结束标签。
[0,0,0,0,32,122,26,65,0,0,0,0,96,123,26,65,0,0,0,0,192,123,20,65,0,0,0,0,0,125,20,65,71,73,70,56,57,97,244,1,244,1,247,0,0,51,85,51,51,85,102,51,85,153,51,85,204,51,85,255,51,128,0,51,128,51,51,128,102,51,128,153,51,128,204,51,128,255,51,170,0,51,170,51,51,170,102,51,170,153,51,170,204,51,170,255,51,213,0,51,213,51,51,213,102,51,213,153,51,213,204,51,213,255,51,255,0,51,255,51,51,255,102,51,255,153,51,255,204,51]
现在,在有人建议将其作为 base64 编码的字符串发送之前,这将需要 Blackberry 实际上有一个工作的 Base64 解码器。但是很可惜,对于超过 64k 的文件,它会失败,并且我已经尝试过alsorts。
无论如何,这是我尝试过的:
str = str.replace('[', ' ');
str = str.replace(']', ' ');
String[] tokens = split(str,",");
byte[] decoded = new byte[tokens.length];
for(int i = 0; i < tokens.length; i++)
{
decoded[i] = (byte)Integer.parseInt(tokens[i]);
}
但它失败了。其中 split 就像在这里找到的 JAVA 实现。
逻辑上它应该工作?但它不是。这是针对JavaME/Blackberry的。请不要 Java 答案(除非他们在 javaME 上工作)。