Hello everyone.
I discovered that java uses a reversed way of storing data. For example, the integer value 2 has the following byte values:
In "Windows" format:
[2] [0] [0] [0]
In "Java" format:
[0] [0] [0] [2]
The binary readers of both languages seem to use the same different format.
Now my question: What is the easiest way to read binary values (Integer, Single, etc.) in VB .NET from a java formatted file?
I already made functions like these:
But they require the (slower) BitConverter to make the read bytes into a value. Is there a "vanilla way" around, some setting for inverted reading in the binary reader or a different class? Or do I have to keep using this Reverse byte method?Code:Private Shared Function revRead(ByVal s As IO.BinaryReader, ByVal length As Integer) As Byte() Dim rval(length - 1) As Byte s.Read(rval, 0, length) Array.Reverse(rval) Return rval End Function Private Shared Function readString(ByVal s As IO.BinaryReader) As String Dim stringlength As Short = BitConverter.ToInt16(revRead(s, 2), 0) Dim chars(stringlength - 1) As Char s.Read(chars, 0, stringlength) Return chars End Function




Reply With Quote