jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Can you explain me this code ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can you explain me this code ??" Watch "Can you explain me this code ??" New topic

Can you explain me this code ??

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830

what this code is doing ?

please help ..

thanks a lot .
Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
Taking a stab even though I've never used any of that really...when you give the ClassLoader the name of the resource, it know where to find it, and gives you the URL so that you can get ahold of it directly. So then you get a file handle to it based on that URL...

I didn't check any of the other code, but that getFile() method did jump out at me...just want you to be sure that file is a String, not a File, because it looks like the getFile() method returns a String of the file's name:
[ February 01, 2005: Message edited by: Stephen Huey ]
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Sounds right, but I haven't used those much either. Normally, getResource(String) is used to locate a file (image, properties, etc) in the classpath. But beware that sometimes that resource is packaged up into a JAR on the classpath. In that case, the URL returned will have a "#resource" at the end, meaning it won't point to a file but rather a resource inside a file.

In other words, that code will not work if the resource is in a JAR. There is, of course, one way to find out . . . try it!
I agree. Here's the link: http://aspose.com/file-tools
subject: Can you explain me this code ??
It's not a secret anymore!