Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How raw data is divided into bytes.

As present audio contains 32bit(2^32 tones) it ranges from 2^0 - 2^32.

ex -> 6710497.. (Considering decimal)

how is it divided to

67 104 97

Does FileInputStream has a method to check like

if(671>256){send 67 , next append 1}

What I have tried:

Java
try(FileInputStream fis=new FileInputStream("We_Dont_Talk_Anymore.mp3")) { //audio file

        int i;
        while((i=fis.read())!=-1)
            System.out.println(i);  
} catch(Exception e) {
    System.out.println(e);
}

o/p-

73 68 51 3 0 0 0 0 1 9 84 73 84 50 0 0 0 76 0 0 0 67 104 97 114 108 105 101 32 80 . . .


Is this correct

i/p -> text '$4-'

36 52 45 (ascii decimal)

00100100 00110100 00101101 (ascii binary)

i/p -> image pixel(rgb) '0,255,100'

00000000 11111111 1100100

i/p -> audio(32 bit, 2^32 tones) '1073741822'

111111111111111111111111111110 (binary form)

00111111 11111111 11111111 11111110 (divide into bytes) [one tone]

63 255 255 254
Posted
Updated 17-Jan-20 14:55pm

Any file, or data, is just a stream of bits. In general it is convenient to handle the stream as a collection 8-bit bytes. However the bytes are often grouped together to make different types of information (int, double, string etc.). The key is that you need to know the structure of the data in order to make sense of it. So the number 6710497 in byte form is 66 64 E1 or as individual values 102 104 225. But what these values represent depends entirely on the actual data that is being processed.
 
Share this answer
 
Comments
49R 17-Jan-20 15:31pm    
how you got this '6710497 in byte form is 66 64 E1'. Is it encoding.
Richard MacCutchan 17-Jan-20 16:00pm    
It is the hexadecimal representation of the decimal number 6710497. But, as I mentioned above, that in itself means nothing. The issues is always, what form is the data being sent in. Is it single byte, double byte (i.e. short), 4-byte (integer) etc. or some random length sequence?
Quote:
How java bytestream works?

In a stream, a byte is the smallest chunk of data you can handle because it is how computer works.
You can consider that a byte is like a digit (for computer), just like for us, a digit is 0-9 for us.
A bytestream have no idea of the meaning of bytes or their organization.
Example: 20200118, it can be 8 number if 1 digit, or 1 number of 8 digit, or 3 numbers of 4 and 2 and 2 digits to encode a date.
Byte - Wikipedia[^]
Bit - Wikipedia[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900