When you create a file via DataOutputStream, what does the binary file look like? It looks like the internal binary RAM (Random Access Memory) format in a big-endian CPU (Central Processing Unit). These are also the internal formats in the Java Virtual Machine.
Everything is stored big endian, MSB (Most Significant Bit) (Most Significant Byte) first. (People who cut their teeth on Intel or the MOS 6502 are used to the little endian LSB (Least Significant Bit) first format.) Even on Intel hardware Java uses big endian file formats. This permits data interchange with other platforms.
There are no separators between fields. The files are in binary, not readable
ASCII.
Method | Type | Size | Description |
---|---|---|---|
writeBoolean(boolean v) | boolean | 1 byte | 8-bit 0x00=false 0x01=true |
writeByte(int v) | byte | 1 byte | 8-bit signed binary integer or 8-bit ASCII char |
writeBytes(String s) | bytes | 1 byte | 8-bit signed binary integers or string of ASCII chars. not null terminated. not in quotes. not counted. not delimited in any way. |
writeChar(int v) | char | 2 byte | 16-bit unsigned binary integer or 16-bit Unicode char. |
writeChars(String s) | chars | 2 byte | 16-bit unsigned binary integers or string of 16-bit Unicode chars. not null terminated. not in quotes. not counted. not delimited in any way. |
writeDouble(double v) | double | 8 bytes | 64-bit IEEE (Institute of Electrical & Electronics Engineers) binary 1-bit sign 11-bit base 2 exponent biased+1023 52-bit fraction, lead 1 implied e.g. 3. = 0x4008000000000000 -3. = 0xC008000000000000 |
writeFloat(float v) | float | 4 bytes | 32-bit IEEE
binary 1-bit sign 8-bit base 2 exponent biased+127 23-bit fraction, lead 1 implied e.g. 3. = 0x404000 -3. = 0xC04000 |
writeInt(int v) | int | 4 bytes | 32-bit signed binary e.g. 3 = >0x00 0x00 0x00 0x03 -3 = 0xff 0xff 0xff 0xfd |
writeLong(long v) | long | 8 bytes | 64-bit signed binary |
writeShort(int v) | short | 2 bytes | 16-bit signed binary |
writeUTF(String s) | utf | 2 bytes | 16-bit length count followed by ASCII-7 string. Not null terminated. ABC == 0x0003414243 non-ASCII-7 chars use multibyte encodings with first byte having the high bit on. |
Unicode | UTF | bytes required to represent the character |
---|---|---|
00000000 0xxxxxxx | 0xxxxxxx | 1 |
00000yyy yyxxxxxx | 110yyyyy 10xxxxxx | 2 |
zzzzyyyy yyxxxxxx | 1110zzzz 10yyyyyy 10xxxxxx | 3 |
This page is posted |
http://mindprod.com/jgloss/binaryformats.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\binaryformats.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[18.97.9.173] |
| |
Feedback |
You are visitor number | |