public static StringFile createStringFileMem(String filename) { return new StringFile(createObjectFileMem(filename)) ; }
@Override protected void removeStringFile(StringFile f) { f.close() ; } }
public String read(long id) { ByteBuffer bb = file.read(id) ; String x = Bytes.fromByteBuffer(bb) ; x = decompress(x) ; return x ; }
public void dump() { dump(handler) ; }
public void flush() { sync() ; }
private void test(long id, String x) { String y = f.read(id) ; assertEquals(x, y) ; } }
public long write(String str) { str = compress(str) ; Block block = file.allocWrite(4*str.length()) ; int len = Bytes.toByteBuffer(str, block.getByteBuffer()) ; block.getByteBuffer().flip() ; file.completeWrite(block) ; return block.getId() ; }
@Test public void object_file_05() { String x = "孫子兵法" ; long id = f.write(x) ; test(0, x) ; }
@Override protected void removeStringFile(StringFile f) { f.close() ; FileOps.delete(fn) ; } }
public static StringFile createStringFileDisk(String filename) { return new StringFile(createObjectFileDisk(filename)) ; }
@Test public void object_file_01() { String x1 = "abc" ; long id1 = f.write(x1) ; test(id1, x1) ; test(0, x1) ; }
@Test public void object_file_02() { String x1 = "" ; long id1 = f.write(x1) ; test(id1, x1) ; test(0, x1) ; }