I am trying to figure out if there is any platform independent way to open a text file with the default text editor even if the file doesn't end in .txt
. I tried following code but it throws exception for files not having .txt
extension. Works perfectly fine for .txt
files.
Desktop dt = Desktop.getDesktop();
try
{
dt.open(fileName);
}
catch(Exception e){
// Catch exception here
}