Depricated code on lines 8, 9, and 10, but its only a warning on line 8

Line 8 gets a warning but lines 9 and 10 cause errors. Anyone see a quick fix?
Thanks
Here is the code:
import java.io.*;
import java.net.*;
public class TimeWaster {
public static void main(String[] args)
String url = URLEncoder.encode(args[0]);
String description = URLEncode.encode(args[1]);
String type = URLEncode.encode(args[2]);
URL site = new URL("http://timewaster.net/");
URLConnection connection = site.openConnection();
connection.setDoOutput(true);
PrintWriter out = new PrintWriter(
connection.getOutputStream());
out.println("url=" + url + "&description=" + description + "&type=" + type);
out.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}

Laszlo, wouldnt that only catch a malformed url. not
make it un-malformed? lolyes, but the compiler doesn't know, at compiltime, whether the url you typed is valid or not. so it's forcing you to handle the case where it is not valid.
i personally don't think these checked exceptions are a good idea, but, it's something you have to live with in java.

Similar Messages

Maybe you are looking for

  • Unable to extract data from an AS/400 system.

    Hello experts. We are trying to extract data from an AS/400 system but not having any success until now. I´ll write down you the stepts that we have followed until now: 1.- Create a DB Connect between both systems 2.- Create a Source System from AS40

  • Using jms names with a / in it...?

    With the following wlst-code I try to create a Jms Uniform Distributed Queue thru wlst. def createJmsUdq(qName,sysName): print 'INFO: createJmsUdq '+qName cd('/') cd('/JMSSystemResources/'+sysName+'/JMSResource/'+sysName) cmo.createUniformDistributed

  • Help undeploying an incorrectly deployed application

    Hi, I deployed a J2EE application to my Application Server PE 8.2 from Net Beans IDE. Even tough all seemed to be ok, after viewing the server log I found out that the deployment didn't complete successfully because of a timeout error. Since then, af

  • AIR for iOS View performance

    In using FB4.6 with AIR 3.4 for iOS on Mac OS X 10.7.4 and when I run this on an iPad 2, one of my views is taking 3.2 secs before it's displayed. I've search for references to things to do to improve the performance I have a View containing a Tabbed

  • CS3 on macbook pro 10.8.5

    I have CS3 which was transferred onto a macbook pro 10.8.5.  Photoshop is now acting independently, giving me grey when I select red, rendering all numbers in the type tool  in italics.  any advice?  Thanks!