Please give me some examples (code on both languages) on how to send float array from c# to Java via sock开发者_Go百科et. Thanks.
I believe you can serialize this array as string [1.25,1.4556,1.34545] and then read this string in Java and de-serialize to array.
I don't like SOAP :)
You cannot directly send them since the two float[] are not interoperable. You have to go for a standard protocol to share them. SOAP
could be one of them.
Text is likely to be the safest way to pass the data. However you can readFloat() using DataInput or via ByteBuffers. There must be a similar option in C#.
You somehow have to convert your floats on one side to bytes, write them to the output-stream of the socket, read them from the input-stream of the socket, and convert those back to floats.
There is the IEEE 754 standard which defines a bit layout - in Java this is implemented by Float.floatToIntBits
and Float.intBitsToFloat
, and also by the readFloat
/writeFloat
methods of DataInputStream.
I suppose there will be a similar method on the .NET side, but I don't know anything about this.
精彩评论