ZipInputStream compressedTcs = new ZipInputStream(backupData);
Map<String, TripleCollection> extractedTc = new HashMap<String, TripleCollection>();
String folder = "";
ZipEntry entry;
Graph metaGraph = null;
while ((entry = compressedTcs.getNextEntry()) != null) {
String entryName = entry.getName();
if (entry.isDirectory()) {
folder = entryName;
} else {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int count;
byte buffer[] = new byte[2048];
while ((count = compressedTcs.read(buffer, 0, 2048)) != -1) {
baos.write(buffer, 0, count);
}
ByteArrayInputStream serializedGraph = new ByteArrayInputStream(
baos.toByteArray());
if (entryName.equals("triplecollections.nt")) {
metaGraph = parser.parse(serializedGraph,
SupportedFormat.N_TRIPLE, null);
} else {
Graph deserializedGraph = parser.parse(serializedGraph,
SupportedFormat.N_TRIPLE, null);
extractedTc.put(entryName, deserializedGraph);
}
baos.flush();
baos.close();