5 Replies Latest reply: Jun 30, 2011 4:27 PM by philfrei RSS

    IOException reading WAV from client via applet

      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) 
          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