Error -- java.lang.ArrayIndexOutOfBoundsException: 0

When trying to write this program:

import java.io.*;

public class ReadID3 {

public static void main(String[] arguments) {

try {

File song = new File(arguments[0]);

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(arguments[0] + " does not contain"

+ "ID3 info.");

}

file.close();

} catch (Exception e) {

System.out.println("Error -- " + e.toString());

}

}

}

I get this error: Error -- java.lang.ArrayIndexOutOfBoundsException: 0

What is happening?

[1075 byte] By [CompilerCama] at [2007-10-2 19:25:51]
# 1

On what line? It would help to post at least the first few lines of the exception. I can see some places that could be a problem though. For example, what if the file is smaller than 128 bytes when you do:

int size = (int)song.length();

file.skip(size - 128);

But without more info I don't know where the problem is. Perhaps at the substring()? Or are you forgetting to pass any arguments to the program?

stdunbara at 2007-7-13 21:11:27 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2
Command line parameter was not specified.
Michael.Nazarov@sun.coma at 2007-7-13 21:11:27 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...