I convert float to byte[] following code:
byte[] bytes = ByteBuffer.allocate(4).putFloat(number).array(); Accordingly, if I convert, for example, the number 0.02f I will receive bytes [60,-93,-41,10] Next, I try to write the received byte[] to the file with the following code:
FileOutputStream fos = new FileOutputStream(file); fos.write(bytes); dbf.close(); On most platforms, the resulting file in the HEX editor looks like this: 3C A3 D7 0A . But on one of the devices instead of the required 4 bytes, I get 5: 3C A3 D7 0D 0A . Before each 0A character 0D 0A independently.
I know that 0A is a carriage return, and 0D is a newline character. But I do not understand how it can appear on its own, because I work with numbers and bytes, and not with strings.
What could be the reason for this behavior and how can I eliminate this bug?