Write Tag Info to a file

In order to make changes to a files metadata you make modifications to the tag class and then commit the changes


AudioFile f = AudioFileIO.read(testFile);
Tag tag = f.getTag();
tag.setField(FieldKey.ARTIST,"Kings of Leon");
f.commit();

or alternatively use the write method()


AudioFile f = AudioFileIO.read(testFile);
Tag tag = f.getTag();
tag.setField(FieldKey.ARTIST,"Kings of Leon");
AudioFileIO.write(f);

We can set fields using set();


tag.set(FieldKey.MUSICBRAINZ_TRACK_ID,"e785f700-c1aa-4943-bcee-87dd316a2c31"));

To add another field of the same type use can use add()


tag.add(FieldKey.ARTIST,"e785f700-c1aa-4943-bcee-87dd316a2c31"));