@Test public void testSetTag() throws InvalidDataException, IOException, UnsupportedTagException, NotSupportedException { for (File testFile: testFileList) { ID3 id3 = new ID3(testFile); SongItem songItem = new SongItem(); songItem.name = testName; songItem.artist = testArtist; boolean result = id3.setTag(songItem); Assert.assertEquals(result, true); } }
public boolean setTag(SongItem songItem) throws IOException, NotSupportedException { ID3v23Tag tag = new ID3v23Tag(); tag.setTitle(songItem.name); tag.setArtist(songItem.artist); tag.setAlbumArtist(songItem.artist); tag.setAlbum(songItem.album); mp3File.setId3v2Tag(tag); File tmpFile = File.createTempFile("id3_", ".tmp"); mp3File.save(tmpFile.getAbsolutePath()); FileInputStream inputStream = new FileInputStream(tmpFile); BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file, false)); byte buffer[] = new byte[BUFFER_SIZE]; int len; while ((len = inputStream.read(buffer, 0, BUFFER_SIZE)) != -1) { outputStream.write(buffer, 0, len); } return tmpFile.delete(); }
ID3 { public boolean setTag(SongItem songItem) throws IOException, NotSupportedException { ID3v23Tag tag = new ID3v23Tag(); tag.setTitle(songItem.name); tag.setArtist(songItem.artist); tag.setAlbumArtist(songItem.artist); tag.setAlbum(songItem.album); mp3File.setId3v2Tag(tag); File tmpFile = File.createTempFile("id3_", ".tmp"); mp3File.save(tmpFile.getAbsolutePath()); FileInputStream inputStream = new FileInputStream(tmpFile); BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file, false)); byte buffer[] = new byte[BUFFER_SIZE]; int len; while ((len = inputStream.read(buffer, 0, BUFFER_SIZE)) != -1) { outputStream.write(buffer, 0, len); } return tmpFile.delete(); } }
ID3 { public boolean setTag(SongItem songItem) throws IOException, NotSupportedException { ID3v23Tag tag = new ID3v23Tag(); tag.setTitle(songItem.name); tag.setArtist(songItem.artist); tag.setAlbumArtist(songItem.artist); tag.setAlbum(songItem.album); mp3File.setId3v2Tag(tag); File tmpFile = File.createTempFile("id3_", ".tmp"); mp3File.save(tmpFile.getAbsolutePath()); FileInputStream inputStream = new FileInputStream(tmpFile); BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file, false)); byte buffer[] = new byte[BUFFER_SIZE]; int len; while ((len = inputStream.read(buffer, 0, BUFFER_SIZE)) != -1) { outputStream.write(buffer, 0, len); } return tmpFile.delete(); } ID3(File file); }
ID3 { public boolean setTag(SongItem songItem) throws IOException, NotSupportedException { ID3v23Tag tag = new ID3v23Tag(); tag.setTitle(songItem.name); tag.setArtist(songItem.artist); tag.setAlbumArtist(songItem.artist); tag.setAlbum(songItem.album); mp3File.setId3v2Tag(tag); File tmpFile = File.createTempFile("id3_", ".tmp"); mp3File.save(tmpFile.getAbsolutePath()); FileInputStream inputStream = new FileInputStream(tmpFile); BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file, false)); byte buffer[] = new byte[BUFFER_SIZE]; int len; while ((len = inputStream.read(buffer, 0, BUFFER_SIZE)) != -1) { outputStream.write(buffer, 0, len); } return tmpFile.delete(); } ID3(File file); boolean setTag(SongItem songItem); }
ID3 { public boolean setTag(SongItem songItem) throws IOException, NotSupportedException { ID3v23Tag tag = new ID3v23Tag(); tag.setTitle(songItem.name); tag.setArtist(songItem.artist); tag.setAlbumArtist(songItem.artist); tag.setAlbum(songItem.album); mp3File.setId3v2Tag(tag); File tmpFile = File.createTempFile("id3_", ".tmp"); mp3File.save(tmpFile.getAbsolutePath()); FileInputStream inputStream = new FileInputStream(tmpFile); BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file, false)); byte buffer[] = new byte[BUFFER_SIZE]; int len; while ((len = inputStream.read(buffer, 0, BUFFER_SIZE)) != -1) { outputStream.write(buffer, 0, len); } return tmpFile.delete(); } ID3(File file); boolean setTag(SongItem songItem);  }