Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

must be caught or declared to be thrown?

843810Feb 22 2003 — edited Feb 22 2003
I keep getting "C:\Documents and Settings\Michael Cojanu.COJANUCOMP\Desktop\JAVA2\urltest4.java:180: unreported exception java.net.MalformedURLException; must be caught or declared to be thrown
startURL("http://www.google.com");"
when I try to compile my program, despite the fact that the exception that error refers to is already thrown...any ideas?

This is the piece of code giving me issues:
public void startURL(String address) throws MalformedURLException, IOException, Exception
{
URL url = new URL(address);
URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
String inputLine;

while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);

in.close();

}


public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()=="MenuStart")
{
startURL("http://www.google.com");
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 22 2003
Added on Feb 22 2003
1 comment
290 views