final long filePointer;
final byte[] buffer = new byte[6 + 9];
String str;
Lyrics3v2Field field;
final Iterator iterator;
ID3v1 id3v1tag = new ID3v1();
id3v1tag = id3v1tag.getID3tag(file);
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 create/update it and write it first.
updateField("IND");
field = (Lyrics3v2Field) this.fieldMap.get("IND");
field.write(file);
iterator = this.fieldMap.values().iterator();
while (iterator.hasNext()) {
field = (Lyrics3v2Field) iterator.next();
final String id = field.getIdentifier();
final boolean save = TagOptionSingleton.getInstance().getLyrics3SaveField(id);
if ((id.equals("IND") == false) && save) {
field.write(file);
}
}
final long size;
size = file.getFilePointer() - filePointer;
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);
}
}