import java.io.*;
public class MP3 {
public static void main(String[] args) {
try {
File song = new File("Sublime - Santeria.mp3");
FileInputStream file = new FileInputStream(song);
int size = (int)song.length();
file.skip(size - 128);
byte[] last128 = new byte[128];
file.read(last128);
String id3 = new String(last128);
String tag = id3.substring(0, 3);
if (tag.equals("TAG")) {
System.out.println("Title: " + id3.substring(3, 32));
System.out.println("Artist: " + id3.substring(33, 62));
System.out.println("Album: " + id3.substring(63, 91));
System.out.println("Year: " + id3.substring(93, 97));
} else
System.out.println(args[0] + " does not contain" + " ID3 information.");
file.close();
} catch (Exception e) {
System.out.println("Error - " + e.toString());
}
}
}
I get the following output:
>javac MP3.java
>Exit code: 0
>java MP3
Title: Santeria
Artist: Sublime
Album: Sublime
Year: 1996
But after the title, artist, and album I get NULNULNULNULNULNUL... for quite a while. I'm not sure if this is because I am just showing the output in a print line statement or if there is another way I could accomplish this task.

New Topic/Question
Reply



MultiQuote



|