Results 1 to 5 of 5
  1. #1
    Doctor Cactus is offline Member
    Join Date
    Oct 2008
    Posts
    63
    Rep Power
    0

    Default What's wrong with this code?

    Hi, I am using the open method Desktop class. I have successfully opened a .txt file with the open method, but when I try to open a .wav or .wmv file, the following error occurs:
    java.io.IOException: Failed to open file Error message: The parameter is incorrect.
    The code is posted below.
    Help is greatly appreciated.



    video1.addActionListener(new ActionListener()
    {
    public void actionPerformed(ActionEvent event)
    {

    try
    {
    Desktop desktop = null;
    if (Desktop.isDesktopSupported())
    {

    desktop = Desktop.getDesktop();
    }

    desktop.open(new File("Videos\\Movie.wmv"));
    }

    catch (IOException ioe)
    {
    ioe.printStackTrace();
    }



    }

    });

  2. #2
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    7

    Default

    I guess it means
    Java Code:
    "Videos\\Movie.wmv"
    that ^ is incorrect. Double slash? (\\)
    I die a little on the inside...
    Every time I get shot.

  3. #3
    Doctor Cactus is offline Member
    Join Date
    Oct 2008
    Posts
    63
    Rep Power
    0

    Default

    no, I used it successfully with the double slash to open a .txt file and also a .pdf file. If I leave out one slash, then the error Illegal escape character occurs. Could it be a problem with the Desktop class itself? Is there some file types that it cannot open?

  4. #4
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    7

    Default

    It might be because of the file format, but I don't know about that. Try renaming the file to Movie.txt or something and than open it with your method. ;)
    I die a little on the inside...
    Every time I get shot.

  5. #5
    Doctor Cactus is offline Member
    Join Date
    Oct 2008
    Posts
    63
    Rep Power
    0

    Default [Solved]

    Hi, I can open the .wmv files through my Java application if MPlayer or VLC Media Player are set as the default media player, but for some reason when Windows Media Player was set as the default application, I got the error described above and strangely,the file will open in Windows Media Player through Windows Explorer.

Similar Threads

  1. What is wrong with this code
    By rosh72851 in forum New To Java
    Replies: 13
    Last Post: 10-31-2008, 02:50 AM
  2. what's wrong with this code?
    By agenteleven in forum Advanced Java
    Replies: 5
    Last Post: 10-07-2008, 12:26 PM
  3. what is wrong with this code
    By masaka in forum New To Java
    Replies: 5
    Last Post: 04-16-2008, 09:27 AM
  4. What's wrong with this code?
    By Wizard wusa in forum New To Java
    Replies: 14
    Last Post: 01-23-2008, 12:55 AM
  5. Is there somethign wrong with this code?
    By Soda in forum New To Java
    Replies: 1
    Last Post: 12-08-2007, 05:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •