首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ID3-TAG JAVA FileOutputStream

ID3-TAG JAVA FileOutputStream
EN

Stack Overflow用户
提问于 2016-10-29 20:39:03
回答 1查看 64关注 0票数 0

嘿,伙计们,我写了一个程序,向我展示了一个MP3文件的ID3标签。现在我想通过write方法来改变ID3标签中的一些东西,比如年份或者标题,但是我是个新手,不知道如何使用这些类。

代码语言:javascript
复制
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);
        }
    }
}
EN

回答 1

Stack Overflow用户

发布于 2016-10-31 16:04:19

我不认为你需要“发明一个轮子”,并建议你使用专门的库来实现:

mp3agic

Beaglebuddy

Jaudiotagger

PS:请阅读如何正确关闭资源(从JDK1.7开始)- The try-with-resources Statement

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40319185

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档