Results 1 to 17 of 17
  1. #1
    Evanxtreme is offline Member
    Join Date
    May 2012
    Posts
    16
    Rep Power
    0

    Question Byte manipulation

    Need help searching for bytes in an InputStream. I need to look for id3v2 frames and headers in mp3 files. I am disgusted with the existing id3 libs (they aint that bad but just annoys me somehow).
    Last edited by DarrylBurke; 06-01-2012 at 05:48 PM. Reason: InputStream not OutputStream

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default Re: Byte manipulation

    Need help searching for bytes
    Can you define what bytes you are looking for and what problems you are having?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Evanxtreme is offline Member
    Join Date
    May 2012
    Posts
    16
    Rep Power
    0

    Default Re: Byte manipulation

    Well, the bytes i'm lookin for is the id3v2 frame headers like the hex representation of "APIC" frame header or "TIT2" etc. Actually i dont have any problem, i just dont how to do !
    Last edited by Evanxtreme; 05-30-2012 at 04:43 PM.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Byte manipulation

    Quote Originally Posted by Evanxtreme View Post
    i just dont how to do !
    Moved from Advanced Java.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default Re: Byte manipulation

    i dont have any problem, i just dont how to do
    Can you post an array containing the bytes you are looking for?

    What is the hex representation of "APIC" ? Why in hex? A byte has two hex digits.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    Evanxtreme is offline Member
    Join Date
    May 2012
    Posts
    16
    Rep Power
    0

    Default Re: Byte manipulation

    Well that would come from any mp3 file as inputstream. And hex reprentation of "APIC" means char "A" would be represented by "0x41" , "C" by "0x44", "I" by "0x49" etc. This is because i'm gonna work with *binary* data (not chars).

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,763
    Blog Entries
    7
    Rep Power
    21

    Default Re: Byte manipulation

    Quote Originally Posted by Evanxtreme View Post
    Well that would come from any mp3 file as inputstream. And hex reprentation of "APIC" means char "A" would be represented by "0x41" , "C" by "0x44", "I" by "0x49" etc. This is because i'm gonna work with *binary* data (not chars).
    Do those four 'characters' take up four bytes? If so, do all those byte values represent valid ASCII code characters? (still they're bytes).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    Evanxtreme is offline Member
    Join Date
    May 2012
    Posts
    16
    Rep Power
    0

    Default Re: Byte manipulation

    Yup! They're four bytes and they are ascii

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,763
    Blog Entries
    7
    Rep Power
    21

    Default Re: Byte manipulation

    Quote Originally Posted by Evanxtreme View Post
    Yup! They're four bytes and they are ascii
    If all those bytes represent valid ASCII characters (in single bytes) you can transform your byte stream to a char stream and fiddle diddle with Strings (there are many more methods available for Strings, e.g. regular expression matching etc.)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    Evanxtreme is offline Member
    Join Date
    May 2012
    Posts
    16
    Rep Power
    0

    Default Re: Byte manipulation

    Oh yeah! But i gotta work with other bytes such as 0x03 0x02 etc. Which i think can't workaround by casting to string :@ and also as an addon Q. How do i trim off (that is, remove) a portion within a file ? Hope its not off-topic ;) .

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,763
    Blog Entries
    7
    Rep Power
    21

    Default Re: Byte manipulation

    Quote Originally Posted by Evanxtreme View Post
    Oh yeah! But i gotta work with other bytes such as 0x03 0x02 etc. Which i think can't workaround by casting to string :@ and also as an addon Q. How do i trim off (that is, remove) a portion within a file ? Hope its not off-topic ;) .
    Byte values 0x02 and 0x03 are valid ASCII values (aamof all bytes in the range 0x00 - 0x7f are valid ASCII values) so they make excellent characters; you probably can't print them but they are valid chars nevertheless ...

    kind regards,

    Jo
    cenosillicaphobia: the fear for an empty beer glass

  12. #12
    Evanxtreme is offline Member
    Join Date
    May 2012
    Posts
    16
    Rep Power
    0

    Default Re: Byte manipulation

    but how do i check that the stream has those bytes ? is there any way to cast hex to string ?

    thanks

  13. #13
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default Re: Byte manipulation

    One way to get hex into a String is to use the escape sequence:

    String str = "\u0003";

    Do you have an example of hex values you want to create a String from?
    If you don't understand my response, don't ignore it, ask a question.

  14. #14
    Evanxtreme is offline Member
    Join Date
    May 2012
    Posts
    16
    Rep Power
    0

    Default Re: Byte manipulation

    Oh nice! I've been using 'very long' steps to get strings from hex, and here is the hex "0x41 0x50 0x49 0x43" and "0xff 0xd8" (i think they aint valid ascii but i want to check them too!) and the code you showed seem to be for unicode char, how do i do that for hex ?

  15. #15
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default Re: Byte manipulation

    Did you try any of those values?
    Java Code:
          String str = "\u0041\u0042\u0043\u00ff\u00d8";
          System.out.println("str=" + str + "<");  // str=ABCÿØ<
    If you don't understand my response, don't ignore it, ask a question.

  16. #16
    Evanxtreme is offline Member
    Join Date
    May 2012
    Posts
    16
    Rep Power
    0

    Default Re: Byte manipulation

    Oh thank you all ! I got it now, thanks again, do this forum have a "problem solved" button ?

  17. #17
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Byte manipulation

    Quote Originally Posted by Evanxtreme View Post
    do this forum have a "problem solved" button ?
    Edit the first post, click 'Go Advanced' and select the prefix.

    This time round, I'm doing it for you.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 1
    Last Post: 10-21-2011, 12:55 PM
  2. textField manipulation
    By Bogdan in forum Advanced Java
    Replies: 3
    Last Post: 12-15-2010, 03:54 AM
  3. Read a bitmap byte by byte
    By cbr400aero in forum Java 2D
    Replies: 2
    Last Post: 10-19-2010, 12:42 AM
  4. String Manipulation
    By tmotse in forum New To Java
    Replies: 1
    Last Post: 10-14-2010, 02:25 PM
  5. Replies: 1
    Last Post: 04-21-2010, 03:28 AM

Posting Permissions

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