KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Following the advice provided in the question https://stackoverflow.com/questions/1738244/what-is-the-java-equivalent-of-net-bitconverter I have begun implementing my own bitconverter for Java but am not getting equivalent results. Could someone please guide me on what I might be doing incorrectly? public static byte[] GetBytes(Integer value) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); DataOutputStream stream = new DataOutputStream(byteStream); try { stream.writeInt(value); } catch (IOException e) { return new byte[4]; } return byteStream.toByteArray(); } byte[] result = BitConverter.GetBytes(1234); //JAVA: [0, 0, 4, -46] byte[] result = BitConverter.GetBytes(1234); //C#: [210, 4, 0, 0]
Tags (comma-separated)
Save Edits
Cancel