java.io.IOException:不支持mark / reset

时间:2015-04-21 15:24:55

标签: java audio input jframe playback

此代码不起作用。我已经准备好了一堂课,因为它可以找到here,但音乐不起作用。我该如何解决这个问题?

private void lblCliqueMouseClicked(java.awt.event.MouseEvent evt){                                     
     lblClique.setText("achou");
     musica = new Som();
     boolean repetir = false; 
     FileInputStream arquivo = null;
     try {
         arquivo = new FileInputStream("musica.mp3");
     } catch (FileNotFoundException ex) {
         Logger.getLogger(TelaProjeto.class.getName()).log(Level.SEVERE, null, ex);
     }
     musica.tocar(arquivo, repetir);
} 

1 个答案:

答案 0 :(得分:7)

不支持错误标记/重置意味着您提供的输入流不支持设置标记并将流重置为该标记。要实现这一点,只需将FileInputStream包装在BufferedInputStream中(参见http://docs.oracle.com/javase/7/docs/api/java/io/BufferedInputStream.html

InputStream arquivo=null;
...
arquivo=new BufferedInputStream(new FileInputStream(...));