aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-12-08 22:11:33 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-12-08 22:11:33 +0900
commitf6a3ae6948b940d0bcc2deddde37cdf2349cfa46 (patch)
tree982de5e91c079ddfde360c649792f8476379627f /src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java
parent9dda9c40514b24b87e33006a0d65fb00e5d62bde (diff)
downloadSkyblock-Dungeons-Guide-f6a3ae6948b940d0bcc2deddde37cdf2349cfa46.tar.gz
Skyblock-Dungeons-Guide-f6a3ae6948b940d0bcc2deddde37cdf2349cfa46.tar.bz2
Skyblock-Dungeons-Guide-f6a3ae6948b940d0bcc2deddde37cdf2349cfa46.zip
put cap for readin
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java b/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java
index dc440405..e3a7e255 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java
@@ -44,16 +44,26 @@ public class NetworkClassLoader extends ClassLoader {
}
private byte[] loadClassFromFile(String fileName) throws BadPaddingException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException, IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException {
- byte[] buffer;
InputStream inputStream = authenticator.getInputStream(fileName.replace('.', '/')+ ".class");
+ long length = 0;
+ {
+ for (int i = 4; i >= 0; i--) {
+ length |= (inputStream.read() & 0xFF) << i * 8;
+ }
+ }
+
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
int nextValue = 0;
try {
- while ( (nextValue = inputStream.read()) != -1 ) {
- byteStream.write(nextValue);
+ byte[] buffer = new byte[1024];
+ while ( (inputStream.read(buffer)) != -1 ) {
+ byteStream.write(buffer);
}
} catch (Exception e) {}
- buffer = byteStream.toByteArray();
- return buffer;
+ byte[] byte1 = byteStream.toByteArray();
+ byte[] byte2 = new byte[(int) length];
+ System.arraycopy(byte1, 0, byte2, 0, byte2.length);
+
+ return byte2;
}
}