Search code examples
swingjnlpjava-web-start

JNLP FileSaveService opens a file open dialog


Hi I'm trying to save a file from a Java Webstart Application.

public class Main {
   public static void main(String[] args) {
      try {
         FileSaveService fos = (FileSaveService) ServiceManager.lookup("javax.jnlp.FileSaveService");
         //open Dialog
         FileContents fc = fos.saveFileDialog("c:/data", null, new ByteArrayInputStream("Hallo Welt".getBytes()), "name.txt");
         System.out.println("FileContents: " + fc);
      } catch (UnavailableServiceException e) {
         System.err.println("***" + e + "***");
      } catch (IOException e) {
         System.err.println("***" + e + "***");
      }
      //wait a minute
      try {
         Thread.sleep(10000);
      } catch (InterruptedException e) {
      }
      System.exit(0);
   }
}

Everything works except that the dialog that comes up looks like a "open" file dialog, not like a "save" file dialog:

FileDialog

Any help would be appreciated.


Solution

  • This seems to be fixed in JRE bersion 1.7.0_21-b11 Java HotSpot(TM) 64-Bit Server VM

    And there it is: https://bugs.java.com/bugdatabase/view_bug?bug_id=2227257