Cross-platform way to open a file using Java 1.5

后端 未结 8 787

I\'m using Java 1.5 and I\'d like to launch the associated application to open the file. I know that Java 1.6 introduced the Desktop API, but I need a solution for J

8条回答
  •  感情败类
    2020-12-16 18:35

    SWT gives you the possibility to lokk for the standard program to open a file via:

    final Program p = Program.findProgram(fileExtension);
    p.execute(file.getAbsolutePath());
    

    Strictly this isn't Cross-Platform since SWT is platform dependent, but for every platform you can use a diffenrent SWT jar.

提交回复
热议问题