Raed Alsaleh
Raed Alsaleh

Reputation: 1621

convert java bytes to c# bytes (serializing issue )

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

Answers (1)

burning_LEGION
burning_LEGION

Reputation: 13450

use protobuf for this purpose, or other some cross-platform serilization (xml, json)

Upvotes: 2

Related Questions