mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-11 18:57:30 +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
|
||||
*/
|
||||
private static byte[] getClassFile(Class<?> clazz) throws IOException {
|
||||
InputStream is = clazz.getResourceAsStream( "/" + clazz.getName().replace('.', '/') + ".class");
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int r = 0;
|
||||
byte[] buffer = new byte[8192];
|
||||
while((r=is.read(buffer))>=0) {
|
||||
baos.write(buffer, 0, r);
|
||||
}
|
||||
return baos.toByteArray();
|
||||
try (InputStream is = clazz.getResourceAsStream( "/" + clazz.getName().replace('.', '/') + ".class");
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
int r = 0;
|
||||
byte[] buffer = new byte[8192];
|
||||
while((r=is.read(buffer))>=0) {
|
||||
baos.write(buffer, 0, r);
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue