Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

IOException reading WAV from client via applet

Phil FreihofnerJun 30 2011 — edited Jun 30 2011
I just managed to enable an Applet to allow reading of files from a client computer, using the JNLP API. The following code returned a diagnostic that indicates the file selected is readable.
    InputStream in = null;
...
    vsg.updateDiagnostic("about to try fos instantiation");
    FileOpenService fos = (FileOpenService) 
    ServiceManager.lookup("javax.jnlp.FileOpenService");
    FileContents contents = fos.openFileDialog(".", new String[] {"wav"});
    if (contents != null) 
    {
        in = contents.getInputStream();
        if (contents.canRead())
        {
            vsg.updateDiagnostic("can read");
        }
    }
However, I am throwing an IOException when I try to instantiate an AudioFileFormat object from this InputStream as follows:
    AudioFileFormat aff = AudioSystem.getAudioFileFormat(in);
The very same WAV file loads fine when I run this program with the following code in an "application" context, where fs is a JFileChooser.
    File soundFile = fs.getSelectedFile().getAbsoluteFile();
    AudioiFileFormat aff = AudioSystem.getAudioFileFormat(soundFile);
An InputStream is considered a valid argument for the getAudioFileFormat() method, yes? And I verified that the newly created InputStream was readable.

Any thoughts on what I might be overlooking? I'm so new to JNLP that I don't know if there is some aspect of the Applet context that is causing a problem. Should I post this question in the JNLP & WebStart forum?

I am posting the Applet at a remote site via FTP, going to the site with a Mozilla Firefox browser, and trying to read a file from my computer's "My Documents" area.

Thank you for your time and help!

Edited by: 807197 on Jun 30, 2011 12:18 AM
This post has been answered by User_64CKJ on Jun 30 2011
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 28 2011
Added on Jun 30 2011
5 comments
2,631 views