open unknown file types through java

Thread Solved
Reply

Join Date: Aug 2008
Posts: 4
Reputation: linu is an unknown quantity at this point 
Solved Threads: 0
linu linu is offline Offline
Newbie Poster

open unknown file types through java

 
0
  #1
Aug 7th, 2008
Hello
Please help me with the following: i am trying to open a file with a specific application using java. I am working on a desktop application.
The following code using java.awt.Desktop works for known extension types,but when trying to open a file with an unknown extension it throws an exception. I know this is about to happen, because it's in the class documentation, but what i want to ask you is if there is another way of popping up the windows "open with" dialog through java. I just don't want to let unknown extension file types untreated. This is the code i use, and it works,just that it throws an exception for unknown file types:

  1. import java.awt.Desktop
  2. ...
  3. if (Desktop.isDesktopSupported()) {
  4. desktop = Desktop.getDesktop();
  5. temp = new File(localPath);
  6. desktop.open(temp);
  7. }

Thank you very much
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 43
Reputation: sanzilla has a little shameless behaviour in the past 
Solved Threads: 3
sanzilla sanzilla is offline Offline
Unverified User

Re: open unknown file types through java

 
0
  #2
Aug 9th, 2008
use the JFileChooser , but that is swing ,

just google and find something about JFileChooser example
http://java.sun.com/docs/books/tutor...lechooser.html

will help you ,
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 4
Reputation: linu is an unknown quantity at this point 
Solved Threads: 0
linu linu is offline Offline
Newbie Poster

Re: open unknown file types through java

 
0
  #3
Aug 9th, 2008
thx,the problem was solved using

String str = "RUNDLL32.EXE SHELL32.DLL,OpenAs_RunDLL";
r = Runtime.getRuntime();
Process p = r.exec(str + "C:\\test.txt");
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC