If anyone has a minute, I could use some help. Been working on this program all day. I know it's hard trying to understand someone's code and logic...but I'm hoping there is an easy solution here.

My program needs to be able to read and write files at the push of a button. However, when I moved my input and output methods to the class that implements ActionListener...I get an IOexcepection error.

Where do I put the "throws IOException" line? I know it usually just goes after the main heading or after each method heading... But what about when I'm using a listener?

For example..this won't work..

public class runProgram implements ActionListener throws IOException

I couldn't get all my code to go in here nicely...so I just pieced some out to help show what I'm trying to do. I did however attach it if anyone wants to look at the mess.

import java.io.File;
import static java.lang.System.out;
import java.util.*;
import java.io.IOException;
import java.io.PrintStream;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class smartMonsterWindow extends JFrame
{

	public static void main (String args[]) throws IOException	
	{
		JFrame window = new smartMonsterWindow();
		window.show();
		//smartMonsterWindow.setSize (200,300);

	}	
	
	public class runProgram implements ActionListener
	{
                         fileInputMethod ();  //Method to Input File   //Exceptions errors here
                         fileOutputMethod (cookieGrid,blocksArray, );  //Method to Output File 
                }

Hi dude
put the try catch block in the actionPerformed event

like this

public class runProgram implements ActionListener{
                       try{
                         fileInputMethod ();  //Method to Input File   //Exceptions errors here
                         fileOutputMethod (cookieGrid,blocksArray, );  //Method to Output File 
                      catch(IOException e}{System.err.println(e);}
                }
}

If anyone has a minute, I could use some help. Been working on this program all day. I know it's hard trying to understand someone's code and logic...but I'm hoping there is an easy solution here.

My program needs to be able to read and write files at the push of a button. However, when I moved my input and output methods to the class that implements ActionListener...I get an IOexcepection error.

Where do I put the "throws IOException" line? I know it usually just goes after the main heading or after each method heading... But what about when I'm using a listener?

For example..this won't work..

public class runProgram implements ActionListener throws IOException

^
No this is not correct

I couldn't get all my code to go in here nicely...so I just pieced some out to help show what I'm trying to do. I did however attach it if anyone wants to look at the mess.

import java.io.File;
import static java.lang.System.out;
import java.util.*;
import java.io.IOException;
import java.io.PrintStream;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class smartMonsterWindow extends JFrame
{

	public static void main (String args[]) throws IOException	
	{
		JFrame window = new smartMonsterWindow();
		window.show();
		//smartMonsterWindow.setSize (200,300);

	}