private byte[] loadClassData(String className) {
ZipInputStream in = null;
FileInputStream fis = null;
try {
fis = new FileInputStream(jarPath);
in = new ZipInputStream(new BufferedInputStream(fis));
ZipEntry entry;
while ((entry = in.getNextEntry()) != null) {
if (entry.getName().contains(".class")) {
String outFileName = entry.getName()
.substring(0, entry.getName().lastIndexOf('.'))
.replace('/', '.');
if (outFileName.equals(className)) {
if (entry.getSize() == -1) {
Log.e("loadClassData", "can't read the file!");
return null;
}
byte[] classData = new byte[(int) entry.getSize()];
in.read(classData);
return classData;
}
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fis.close();
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
При отладке я всегда получаю размер "in" 512 байт, так что я не могу получить оставшуюся часть моего файла, и я не знаю почему. Есть ли у ZipInputStream ограничение размера?
Спасибо!