I'm just starting to learn Java, and for my first challenge I am trying to read the ID3v1 tag from an MP3. I read the last 128 bytes of an MP3 in to a byte array and split it up from there. To check I have found a valid ID3 tag I convert the first 3 bytes from the array in to a string and compare it to "TAG". The problem is the string made up from the bytes never matches the "TAG" string, even though it looks like it should when I run it in the eclipse debugger.
I've pasted the code I'm using below, Can anyone please point out what it is I am doing wrong here?
byte tagBytes[] = {84, 65, 71}; //Normally filed from a file, just here as an example.
String tagHeader = null; //String to hold tag header
tagHeader = Character.toString((char)tagBytes[0]) +
Character.toString((char)tagBytes[1]) +
Character.toString((char)tagBytes[2]);
if (tagHeader != "TAG"){
System.out.println("No ID3v1 tag found");
return null;
}