尝试使用JavaFX导入mp3文件时出错

尝试使用JavaFX导入mp3文件时出错,java,macos,javafx,Java,Macos,Javafx,因此,我尝试运行我的应用程序,它在终端中向我发出以下警告: Jan 12, 2015 8:57:00 PM com.sun.javafx.tk.quantum.PrismImageLoader2$PrismLoadListener imageLoadWarning WARNING: null Jan 12, 2015 8:57:00 PM com.sun.javafx.tk.quantum.PrismImageLoader2$PrismLoadListener imageLoadWarning

因此,我尝试运行我的应用程序,它在终端中向我发出以下警告:

Jan 12, 2015 8:57:00 PM com.sun.javafx.tk.quantum.PrismImageLoader2$PrismLoadListener imageLoadWarning
WARNING: null
Jan 12, 2015 8:57:00 PM com.sun.javafx.tk.quantum.PrismImageLoader2$PrismLoadListener imageLoadWarning
WARNING: Corrupt JPEG data: premature end of data segment`
它将在
/Dir
中播放两首歌曲(共六首),然后意外停止

我怎样才能让它不抛出这个警告?我如何让它通过整个目录

public void getMusicDirectory() {
    try {
        File folder = new File("./Dir");
        File[] contents = folder.listFiles();
        for (int i = 0; i < contents.length; i++) {
            String name = contents[i].getName();
            //System.out.println(name);

            if (name.indexOf(".mp3") == -1) {
                continue;
            }

            //System.out.println(name + "continuing");
            FileInputStream file = new FileInputStream(contents[i]);
            int size = (int)contents[i].length();
            //System.out.println(size);
            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")) {
                songsDir.add(new Song((new MediaPlayer(new Media(contents[i].toURI().toString()))),id3));
                file.close();
            } else
                file.close();
        }
    } catch (Exception e) {
        System.out.println("Error -- " + e.toString());
    }
}
public void getMusicDirectory(){
试一试{
文件夹=新文件(“./Dir”);
File[]contents=folder.listFiles();
for(int i=0;i

这就是我正在使用的代码。我不明白为什么它不会遍历所有文件,或者为什么它会触发警告。

我遇到了一个几乎类似的问题,似乎问题出在我使用的数据类型上。我在我的maria db数据库中使用了blob,但一旦我将其更改为LONGBLOB,它就工作得非常好。我试图将图像从数据库加载到javafx Imageview

一些问题:1。在同一个文件上总是失败吗?(例如,尝试只加载失败的单个文件。)2。是否有关于错误的更多详细信息(例如堆栈跟踪等)?3.你的
歌曲
类是否在某处加载图像?