The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Yes, you can...

Posted by Kishori Sharan on January 04, 2001 at 12:03 PM

You can do that. Check the file extension and then create an array of String as follows.
String[] cmd = new String[2] ;

// Get the file name and check the file extension
String fileName = getFileName ( ) ;
cmd[1] = fileName ;

// Now based on file extension use the application to open it
if ( fileExtension.equals ( ".jpg" ) {
cmd[0] = "...\\iexplore.exe" ;

}

// Now open the file
Runtime.getRuntime().exec( cmd ) ;

I ran the following hard coded values and it works.
String[] cmd = { "c:\\kishori\\iexplore.exe", "c:\\kishori\\dhr.jpg" } ;
Runtime.getRuntime().exec ( cmd ) ;

Thanx
Kishori



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us