Ok i have a mthod that writes data to a file and throws an exception
import java.io.*;
public void writeBook()throws IOException
{
String filename = JOptionPane.showInputDialog("Please enter a file name to add the book details in.");
FileWriter outputFile = new FileWriter(filename);
BufferedWriter outputBuffer = new BufferedWriter(outputFile);
PrintWriter printStream = new PrintWriter(outputBuffer);
for(int i=1;i<bookIndex;i++)
{
printStream.println(books[i].getTitle());
printStream.println(books[i].getNoOfCopies());
printStream.println(books[i].getBookNo());
printStream.println(books[i].getAuthor());
}
printStream.close();
}
The problem is that if i try to call this method ( like this: writeBook(); ) from somewhere else in the class, it gives me an error:
unreported exception java.io.IOException; must be caught or declared to be thrown
HELP???