lout.close();
long lId = lh.getId();
lh.close();
// check for sanity
lh = bkc.openLedger(lId, digestType, ledgerPassword);
LedgerInputStream lin = new LedgerInputStream(lh, 1);
byte[] bread = new byte[b.length];
int read = 0;
while (read < b.length) {
read = read + lin.read(bread, read, b.length);
}
String newString = new String(bread);
assertTrue("these two should same", toWrite.equals(newString));
lin.close();
lh.close();
// create another ledger to write one byte at a time
lh = bkc.createLedger(digestType, ledgerPassword);
lout = new LedgerOutputStream(lh);
for (int i = 0; i < b.length; i++) {
lout.write(b[i]);
}
lout.close();
lId = lh.getId();
lh.close();
lh = bkc.openLedger(lId, digestType, ledgerPassword);
lin = new LedgerInputStream(lh);
bread = new byte[b.length];
read = 0;
while (read < b.length) {
read = read + lin.read(bread, read, b.length);
}
newString = new String(bread);
assertTrue("these two should be same ", toWrite.equals(newString));
lin.close();
lh.close();
}