1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/usage/Main.java Sun Feb 01 16:29:46 2009 +0100
1.3 @@ -0,0 +1,35 @@
1.4 +package org.apidesign.exceptions.trycatchredo.usage;
1.5 +
1.6 +import java.awt.EventQueue;
1.7 +import java.awt.event.ActionEvent;
1.8 +import java.net.URL;
1.9 +import javax.swing.Action;
1.10 +import org.apidesign.exceptions.trycatchredo.api.IOManager;
1.11 +import org.apidesign.exceptions.trycatchredo.api.UserQuestionException;
1.12 +
1.13 +/** Sample usage showing interactive storage capabilities of the
1.14 + * {@link UserQuestionException}
1.15 + *
1.16 + * @author Jaroslav Tulach <jtulach@netbeans.org>
1.17 + */
1.18 +public class Main {
1.19 + public static void main(String[] args) throws Exception {
1.20 + MemoryURL.initialize();
1.21 +
1.22 + for (int cnt = 0; cnt < 10; cnt++) {
1.23 + URL u = new URL("memory://" + cnt + "/queryEncoding.txt");
1.24 + MemoryURL.registerURL(u.toExternalForm(), "", new QueryStream());
1.25 + final Action a = IOManager.createSaveAction(u, "Ask a Question");
1.26 + EventQueue.invokeAndWait(new Runnable() {
1.27 + public void run() {
1.28 + a.actionPerformed(new ActionEvent(this, 0, ""));
1.29 + }
1.30 + });
1.31 + String out = MemoryURL.getOutputForURL(u.toExternalForm());
1.32 +
1.33 + System.err.println(cnt + " output: " + out);
1.34 + }
1.35 +
1.36 + System.exit(0);
1.37 + }
1.38 +}