mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-18 22:13:04 +03:00
[FIX] Закрываем ресурсы в LauncherAgent.
This commit is contained in:
parent
3f4d857e27
commit
de2e53dfc2
1 changed files with 9 additions and 8 deletions
|
@ -147,13 +147,14 @@ private static byte[] transformClass(String className, byte[] classBytes) {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private static byte[] getClassFile(Class<?> clazz) throws IOException {
|
private static byte[] getClassFile(Class<?> clazz) throws IOException {
|
||||||
InputStream is = clazz.getResourceAsStream( "/" + clazz.getName().replace('.', '/') + ".class");
|
try (InputStream is = clazz.getResourceAsStream( "/" + clazz.getName().replace('.', '/') + ".class");
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||||
int r = 0;
|
int r = 0;
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
while((r=is.read(buffer))>=0) {
|
while((r=is.read(buffer))>=0) {
|
||||||
baos.write(buffer, 0, r);
|
baos.write(buffer, 0, r);
|
||||||
}
|
}
|
||||||
return baos.toByteArray();
|
return baos.toByteArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue