Results 1 to 6 of 6
  1. #1
    Krooger is offline Member
    Join Date
    Nov 2008
    Posts
    43
    Rep Power
    0

    Question Best way to do the following?

    I have an array of type byte[4] that is length four.
    These bytes all combined together represent a single number
    I need to add a variable number to this representation.
    What is the easiest way to do this?

    So for example lets assume the four bytes represent the number 32453245, I need to add lets say 53445 to the number representing in the array.

    Thank You

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    What is the easiest way to do this?

    So for example lets assume the four bytes represent the number 32453245, I need to add lets say 53445 to the number representing in the array.

    32453245+53445?

    But surely you mean something else?

  3. #3
    Krooger is offline Member
    Join Date
    Nov 2008
    Posts
    43
    Rep Power
    0

    Default

    What I am trying exactly to do is take a WAV file and edit it.
    When I do this I need to change the 5-8 bytes in this file because these four bytes represent the whole file size. When I edit the WAV file the size will always grow, so what I need to do is take what ever number is represented by these four bits add integer X to this number and then store it back in these four bits.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    OK. Let me make a wild guess...

    You say

    These bytes all combined together represent a single number
    But do you know how the bytes represent a number? If not you will have to google about, find and read the specifications for a .wav file.

  5. #5
    Krooger is offline Member
    Join Date
    Nov 2008
    Posts
    43
    Rep Power
    0

    Default

    Yes i know how they combine to make a number, I do not however know how in java to make them do so. an array of 4 bytes is usless to me, i need ot know the int value.

  6. #6
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Yes i know how they combine to make a number, I do not however know how in java to make them do so.

    Good. Perhaps if you describe the process someone will be able to say how it might be written as Java code. (And the reverse, because you will need that after you have figured out the new file length.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •