Ooh … Begitu! I see, I see …


Setelah kelayapan di internet, cari-cari info dari sana-sini dan bongkar pasang tips (terutama programming), akhirnya baru sadar … ternyata begitu caranya … [all about tricks and tips I have found during my work as programmer.]

deprecated File toURL() method in Java 6

after upgrading to Java 6, I just found out that toURL() method is deprecated in Java 6.
after doing some googling, I reached to this page: http://www.jguru.com/faq/view.jsp?EID=1280051

The author (in the link above) said:

The toURL() method of File does not properly escape characters that aren’t valid in a URL. You can write better code today without waiting for Java 6 by calling the toURL() method after calling toURI() on a File object.

and provided these code samples for us:

    URL url1 = file.toURL();         // bad
    URL url2 = file.toURI().toURL(); //good

hmmm … okay, I got it.

Filed under: Java programming, , , , , , , , ,

One Response

  1. Yo man says:


    :: Bongkar Pasang ::

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: