1
我會從Ancroid客戶端向Java服務器發送雙數組。對於這個puropose,我開始INT使用Base64轉換爲字節數組客戶端,然後對其進行編碼,現在如何將字節數組轉換爲雙數組
,我想知道如何進行反向操作,例如接收的字節數組[]轉換回雙陣列[]
我用這個方法在客戶端
public byte[] toByteArray(double[] from) {
byte[] output = new byte[from.length*Double.SIZE/8];
int step = Double.SIZE/8;
int index = 0;
for(double d : from){
for(int i=0 ; i<step ; i++){
long bits = Double.doubleToLongBits(d);
byte b = (byte)((bits>>>(i*8)) & 0xFF);
int currentIndex = i+(index*8);
output[currentIndex] = b;
}
index++;
}
return output;
}
只要做你在做什麼反客戶端,輕鬆。如果顯示在客戶端上轉換你的確切代碼,然後我們可能能夠幫助,但它應該是相當直截了當 – musefan