Click here to Skip to main content
14,494,237 members
Rate this:
Please Sign up or sign in to vote.
See more:
I want to open a file through a java program.The file should open in the system's default program.
for e.g.:a text file should open in notepad.
an image should open in default image viewer.

what are the possible ways of implementing this?

i want to write a function to which i will pass an object of class File and the function has to open the file.


1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

File file = new File("myFile.txt");

ankit_khedekar 14-Aug-11 8:19am
thanks for your reply
this is working well for all files except mp3 files.the mp3 does not play and gives an exception"unspecified error".even the videos files open perfectly in the media player classic so why dont the mp3 files

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100