byte[] buffer = new byte[6 + 9];
String str;
Lyrics3v2Field field;
Iterator<Lyrics3v2Field> iterator;
ID3v1Tag id3v1tag;
new ID3v1Tag();
id3v1tag = null;
delete(file);
file.seek(file.length());
filePointer = file.getFilePointer();
str = "LYRICSBEGIN";
for (int i = 0; i < str.length(); i++) {
buffer[i] = (byte) str.charAt(i);
}
file.write(buffer, 0, str.length());
// IND needs to go first. lets createField/update it and write it first.
updateField("IND");
field = fieldMap.get("IND");
field.write(file);
iterator = fieldMap.values().iterator();
while (iterator.hasNext()) {
field = iterator.next();
String id = field.getIdentifier();
boolean save = TagOptionSingleton.getInstance().getLyrics3SaveField(id);
if ((!id.equals("IND")) && save) {
field.write(file);
}
}
size = file.getFilePointer() - filePointer;
if (this.getSize() != size) {
//logger.info("Lyrics3v2 size didn't match up while writing.");
//logger.info("this.getsize() = " + this.getSize());
//logger.info("size (filePointer) = " + size);
}
str = Long.toString(size);
for (int i = 0; i < (6 - str.length()); i++) {
buffer[i] = (byte) '0';
}
offset += (6 - str.length());
for (int i = 0; i < str.length(); i++) {
buffer[i + offset] = (byte) str.charAt(i);
}
offset += str.length();
str = "LYRICS200";
for (int i = 0; i < str.length(); i++) {
buffer[i + offset] = (byte) str.charAt(i);
}
offset += str.length();
file.write(buffer, 0, offset);
if (id3v1tag != null) {
id3v1tag.write(file);
}
}