/* WebStartTest2.java */

import java.io.*;
import javax.jnlp.*;

public class WebStartTest2
{
  public static void main(String[] args)
  {
    try {
      //FileOpenService anfordern
      FileOpenService fos = (FileOpenService)ServiceManager.lookup(
        "javax.jnlp.FileOpenService"
      );
      //DateiÖffnen-Dialog aufrufen
      FileContents fc = fos.openFileDialog(null, null);
      if (fc == null) {
        System.err.println("openFileDialog fehlgeschlagen");
      } else {
        //Dateiinhalt auf der Konsole ausgeben
        InputStream is = fc.getInputStream();
        int c;
        while ((c = is.read()) != -1) {
          System.out.print((char)c);
        }
        is.close();
      }
    } catch (UnavailableServiceException e) {
      System.err.println("***" + e + "***");
    } catch (IOException e) {
      System.err.println("***" + e + "***");
    }
    //10 Sekunden warten, dann Programm beenden
    try {
      Thread.sleep(10000);
    } catch (InterruptedException e) {
    }
    System.exit(0);
  }
}