I have run into a curious issue. I need to export some text to a file as a result of pressing a button in a GUI. I cannot, however, apply an IOException to the actionPerformed method of the AbstractAction that is called by the event. I am at a loss as to how to get around this.
Here is the export class:
import java.awt.event.*;
import java.lang.*;
import java.util.*;
import java.io.*;
public class ExportRunner
{
public static void exportToFile(ArrayList<Locker> list) throws IOException
{
}
}
And the AbstractAction extension:
class Export extends AbstractAction
{
public Export()
{
super("Export");
}
public void actionPerformed(ActionEvent e)
{
ExportRunner.exportToFile(list);
}
}
First of all are you sure you want to re throw the exception or maybe is better to handle it and/or show a message to the user?
Option 1: re-throw the exception (ugly in my opinion):
Option 2: catch and handle it: