2016-10-29 18 views
0

ちょっと私は私にMP3ファイルのID3タグを示すプログラムを書いた。 私はそのID3-TAGの中でwrite-methodを使って年やタイトルなどのいくつかのものを変更したいと思っています。しかし、私はこれらのクラスを使うのが初めてで、実際の使い方を知らないです。ID3-TAG JAVA FileOutputStream

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

私の答えはどんな運がありますか? –

答えて

0

私は、あなたが "車輪を発明" する必要はないと思いますし、そのために使用特別なライブラリを提案したいと思います:

mp3agic
Beaglebuddy
Jaudiotagger

PS:お読みください正しいリソースを閉じる方法(JDK 1.7以降) - The try-with-resources Statement

関連する問題