Reputation: 1621
in the following I tried to make some sort of magi-ration between Java serialize text file stored in amazon to c# deserialize object. my idea is to convert signed bytes in Java to Unsigned bytes in .net ! but Unfortunately it doesn't work ! does it valid idea ? how could I solve that ?
using (Stream amazonStream = getObjRespone.ResponseStream)
{
List<sbyte> buffer = new List<sbyte>();
int onebyte = 0;
while (onebyte != -1)
{
onebyte = amazonStream.ReadByte();
if (onebyte != -1)
buffer.Add((sbyte)onebyte);
}
byte[] dest = Array.ConvertAll(buffer.ToArray(), item => (byte)item);
Stream stream = new MemoryStream(dest);
object obj= binaryFormatter.Deserialize(stream);
//byte[] b= (byte[]) buf.ToArray();
}
Upvotes: 1
Views: 398
Reputation: 13450
use protobuf
for this purpose, or other some cross-platform serilization (xml, json)
Upvotes: 2