I am getting a "unreported exception java.io.ioexception must be caught or declared to be thrown" for some reason. I throw an I/O exception in this method:
private void setChar() throws IOException
{
try
{
int data = in.read();
if(data==-1)
{
eof = true;
}
else
{
currentChar = (char) data;
}
}
catch (IOException e)
{
System.exit(0);
}
}
And I call the method here (in the constructors):
private BufferedReader in;
private char currentChar;
private boolean done;
public Scanner(InputStream inStream)
{
in = new BufferedReader(new InputStreamReader(inStream));
done = false;
getNextChar();
}
public Scanner(String inString)
{
in = new BufferedReader(new StringReader(inString));
done = false;
setChar();
}
Am I calling / throwing the exception wrong?