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). :(emo):
Printable View
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). :(emo):
Can you define what bytes you are looking for and what problems you are having?Quote:
Need help searching for bytes
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 !
Can you post an array containing the bytes you are looking for?Quote:
i dont have any problem, i just dont how to do
What is the hex representation of "APIC" ? Why in hex? A byte has two hex digits.
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).
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
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 ;) .
but how do i check that the stream has those bytes ? is there any way to cast hex to string ?
thanks
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?
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 ?
Did you try any of those values?
Code:String str = "\u0041\u0042\u0043\u00ff\u00d8";
System.out.println("str=" + str + "<"); // str=ABCÿØ<
Oh thank you all ! I got it now, thanks again, do this forum have a "problem solved" button ?