samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/usage/Main.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sun, 01 Feb 2009 16:29:46 +0100
changeset 312 0678c9589013
permissions -rw-r--r--
Renaming the project to 'Try Catch Redo'
     1 package org.apidesign.exceptions.trycatchredo.usage;
     2 
     3 import java.awt.EventQueue;
     4 import java.awt.event.ActionEvent;
     5 import java.net.URL;
     6 import javax.swing.Action;
     7 import org.apidesign.exceptions.trycatchredo.api.IOManager;
     8 import org.apidesign.exceptions.trycatchredo.api.UserQuestionException;
     9 
    10 /** Sample usage showing interactive storage capabilities of the
    11  * {@link UserQuestionException}
    12  *
    13  * @author Jaroslav Tulach <jtulach@netbeans.org>
    14  */
    15 public class Main {
    16     public static void main(String[] args) throws Exception {
    17         MemoryURL.initialize();
    18         
    19         for (int cnt = 0; cnt < 10; cnt++) {
    20             URL u = new URL("memory://" + cnt + "/queryEncoding.txt");
    21             MemoryURL.registerURL(u.toExternalForm(), "", new QueryStream());
    22             final Action a = IOManager.createSaveAction(u, "Ask a Question");
    23             EventQueue.invokeAndWait(new Runnable() {
    24                 public void run() {
    25                     a.actionPerformed(new ActionEvent(this, 0, ""));
    26                 }
    27             });
    28             String out = MemoryURL.getOutputForURL(u.toExternalForm());
    29 
    30             System.err.println(cnt + " output: " + out);
    31         }
    32 
    33         System.exit(0);
    34     }
    35 }