嘿,伙计们,我写了一个程序,向我展示了一个MP3文件的ID3标签。现在我想通过write方法来改变ID3标签中的一些东西,比如年份或者标题,但是我是个新手,不知道如何使用这些类。
import java.io.*;
import java.util.*;
public class MP3Auslesen {
public static void main(String[] args) {
long groesseMP3 = 0;
byte bTAG[] = new byte[3];
byte bTitel[] = new byte[30];
byte bInterpret[] = new byte[30];
byte bCDTitel[] = new byte[30];
byte bJahr[] = new byte[30];
byte bKommentar[] = new byte[30];
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.println("MP3-Datei: ");
String filename = in.readLine();
FileInputStream fis = new FileInputStream(filename);
groesseMP3 = fis.available();
fis.skip(groesseMP3 - 128);
fis.read(bTAG);
String strTAG = new String(bTAG);
fis.read(bTitel);
String strTitel = new String(bTitel);
fis.read(bInterpret);
String strInterpret = new String(bInterpret);
fis.read(bCDTitel);
String strCDTitel = new String(bCDTitel);
fis.read(bJahr);
String strJahr = new String(bJahr);
String strKommentar = new String(bKommentar);
fis.read(bKommentar);
byte bGenre = (byte) fis.read();
System.out.println("Dateigröße : " + groesseMP3);
System.out.println("TAG : " + strTAG);
System.out.println("Titel :" + strTitel);
System.out.println("Interpret :" + strInterpret);
System.out.println("CD-Titel : " + strCDTitel);
System.out.println("Jahr :" + strJahr);
System.out.println("Kommentar : " + strKommentar);
System.out.println("Genre : " + bGenre);
fis.close();
} catch (IOException err) {
System.out.println("Fehler" + err);
}
}
}发布于 2016-10-31 16:04:19
我不认为你需要“发明一个轮子”,并建议你使用专门的库来实现:
Beaglebuddy
Jaudiotagger
PS:请阅读如何正确关闭资源(从JDK1.7开始)- The try-with-resources Statement
https://stackoverflow.com/questions/40319185
复制相似问题