java.io.IOException: mark/reset not supported

≯℡__Kan透↙ 提交于 2019-12-08 02:50:02

问题


This code does not work. I took a class ready since it can be found here, but the music does not work. How can I fix this?

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:


The error mark/reset not supported means the input stream you provided does not support setting a mark and resetting the stream to that mark. To achieve this, just wrap your FileInputStream inside a BufferedInputStream (see http://docs.oracle.com/javase/7/docs/api/java/io/BufferedInputStream.html)

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


来源:https://stackoverflow.com/questions/29776564/java-io-ioexception-mark-reset-not-supported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!