jtulach@312: package org.apidesign.exceptions.trycatchredo.usage; jtulach@312: jtulach@312: import java.awt.EventQueue; jtulach@312: import java.awt.event.ActionEvent; jtulach@312: import java.net.URL; jtulach@312: import javax.swing.Action; jtulach@312: import org.apidesign.exceptions.trycatchredo.api.IOManager; jtulach@312: import org.apidesign.exceptions.trycatchredo.api.UserQuestionException; jtulach@312: jtulach@312: /** Sample usage showing interactive storage capabilities of the jtulach@312: * {@link UserQuestionException} jtulach@312: * jtulach@312: * @author Jaroslav Tulach jtulach@312: */ jtulach@312: public class Main { jtulach@312: public static void main(String[] args) throws Exception { jtulach@312: MemoryURL.initialize(); jtulach@312: jtulach@312: for (int cnt = 0; cnt < 10; cnt++) { jtulach@312: URL u = new URL("memory://" + cnt + "/queryEncoding.txt"); jtulach@312: MemoryURL.registerURL(u.toExternalForm(), "", new QueryStream()); jtulach@312: final Action a = IOManager.createSaveAction(u, "Ask a Question"); jtulach@312: EventQueue.invokeAndWait(new Runnable() { jtulach@312: public void run() { jtulach@312: a.actionPerformed(new ActionEvent(this, 0, "")); jtulach@312: } jtulach@312: }); jtulach@312: String out = MemoryURL.getOutputForURL(u.toExternalForm()); jtulach@312: jtulach@312: System.err.println(cnt + " output: " + out); jtulach@312: } jtulach@312: jtulach@312: System.exit(0); jtulach@312: } jtulach@312: }