... but I should actually use a ByteArrayOutputStream to avoid
breaking up unicode characters that might span the 65536-byte boundary
of my input buffer:
private boolean readEpubFile() {
FileInputStream f = null;
ZipInputStream z = null;
byte buffer[] = new byte[65536];
try {
f = new FileInputStream(this.file);
z = new ZipInputStream(f);
ZipEntry ze;
while ((ze = z.getNextEntry()) != null) {
ByteArrayOutputStream bs = new
ByteArrayOutputStream();
int len = 0;
while ((len = z.read(buffer)) > 0) {
bs.write(buffer, 0, len);
}
byte[] bytes = bs.toByteArray();
if (this.itemMap == null) {
this.itemMap = new LinkedHashMap<String,
String>();
}
String name = ze.getName();
String content = new String(bytes);
this.itemMap.put(name, content);
}
}
catch (Throwable t) {
return (false);
}
return (true);
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en