classloader - Get size of jar file loaded by urlclassloader -


Do anyone know a good way to find the file size dynamically loaded by URLClasLoader?

I am using urlclassloader in the following manner, but it needs to be kept track of how much bandwidth is being used.

  URLClassLoader sysloader = (URLClassLoader) ClassLoader .getSystemClassLoader); Class & lt; URLClassLoader & gt; Sysclass = URLClassLoader.class; Method method = sysclass.getDeclaredMethod ("addURL", parameter); Method.setAccessible (true); Method.invoke (sysloader, (object []) urls;  

Thank you in advance!

If you know the URL, there are loaded http URLs, and you can ensure that The server they are on gives content-length headers, you can get their size from the following:

  throws public static getcontentLength (URL url) IOException {String contentLength = Url.openConnection (). GetHeaderField ("content-length"); If (contentLength == faucet) {new illegal sold sold (url + "" was not "+ content-length header"); } Else {return Integer.parseInt (contentLength); }}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -