Guest User

Untitled

a guest
Jun 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. URLClassLoader sysloader = (URLClassLoader) ClassLoader
  2. .getSystemClassLoader();
  3. Class<URLClassLoader> sysclass = URLClassLoader.class;
  4. Method method = sysclass.getDeclaredMethod("addURL", parameters);
  5. method.setAccessible(true);
  6. method.invoke(sysloader, (Object[]) urls);
  7.  
  8. public static int getContentLength (URL url)
  9. throws IOException
  10. {
  11. String contentLength = url.openConnection().getHeaderField("Content-Length");
  12. if (contentLength == null) {
  13. throw new IllegalArgumentException(url + " didn't have a "
  14. + "Content-Length header");
  15. } else {
  16. return Integer.parseInt(contentLength);
  17. }
  18. }
Add Comment
Please, Sign In to add comment