【问题标题】:ID3-TAG JAVA FileOutputStreamID3-TAG JAVA FileOutputStream
【发布时间】:2016-10-29 12:39:03
【问题描述】:

大家好,我编写了一个程序,可以显示 MP3.file 的 ID3-Tag。 现在我想通过使用 write-method 更改 ID3-TAG 中的一些内容,例如年份或标题。但我是新手,不知道如何使用它们。

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);
        }
    }
}

【问题讨论】:

  • 我的回答好运吗?

标签: java fileoutputstream id3


【解决方案1】:

我认为您不需要“发明轮子”,并建议为此使用特殊库:

mp3agic
Beaglebuddy
Jaudiotagger

PS:请阅读如何正确关闭资源(自 JDK 1.7 起)- The try-with-resources Statement

【讨论】:

    猜你喜欢
    • 2015-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-18
    • 2015-12-24
    • 2013-11-28
    • 2023-04-10
    • 2021-02-21
    相关资源
    最近更新 更多