@@ -0,0 +1,2369 @@
+package pstore.examples;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport pstore.*;%0A%0Aimport static pstore.PStoreFileMode.READ_ONLY;%0Aimport static pstore.PStoreFileMode.WRITE_ONLY;%0A%0Apublic class PStore %7B%0A  static %7B System.loadLibrary(%22pstore-java%22); %7D%0A%0A  private static final String FILENAME = %22/tmp/pstore-%22 + System.currentTimeMillis() + %22.pstore%22;%0A%0A  public static void main(String%5B%5D args) %7B%0A    writeDatabase();%0A    printDatabase();%0A  %7D%0A%0A  private static void writeDatabase() %7B%0A    PStoreFile file = new PStoreFile(FILENAME, WRITE_ONLY);%0A    writeTable(table(), rows(), file);%0A    file.close();%0A  %7D%0A%0A  private static void writeTable(Table table, List%3CRow%3E rows, PStoreFile output) %7B%0A    Header header = createHeader(table);%0A    header.write(output);%0A    IteratorState state = new IteratorState(rows.iterator());%0A    table.importValues(output, state);%0A    header.write(output);%0A    state.release();%0A    header.release();%0A  %7D%0A%0A  private static void printDatabase() %7B%0A    PStoreFile input = new PStoreFile(FILENAME, READ_ONLY);%0A    Header header = Header.read(input);%0A    for (Table table : header.getTables())%0A      printTable(table, input);%0A  %7D%0A%0A  private static void printTable(Table table, PStoreFile input) %7B%0A    for (Column col : table.getColumns())%0A      printColumn(col, input);%0A  %7D%0A%0A  private static void printColumn(Column col, PStoreFile input) %7B%0A    Segment segment = Segment.read(col, input);%0A    for (;;) %7B%0A      String value = segment.next();%0A      if (value == null)%0A        break;%0A      System.out.println(value);%0A    %7D%0A    segment.release();%0A  %7D%0A%0A  private static Table table() %7B%0A    Table table = new Table(%22table%22, 0);%0A    for (Column column : columns())%0A      table.add(column);%0A    return table;%0A  %7D%0A%0A  private static List%3CColumn%3E columns() %7B%0A    List%3CColumn%3E cols = new ArrayList%3CColumn%3E();%0A    cols.add(new Column(%22Column1%22, 0, ValueType.STRING));%0A    cols.add(new Column(%22Column2%22, 1, ValueType.STRING));%0A    cols.add(new Column(%22Column3%22, 2, ValueType.STRING));%0A    return cols;%0A  %7D%0A%0A  private static List%3CRow%3E rows() %7B%0A    List%3CRow%3E rows = new ArrayList%3CRow%3E();%0A    rows.add(new Row(%22col1.1%22, %22col1.2%22, %22col1.3%22));%0A    rows.add(new Row(%22col2.1%22, %22col2.2%22, %22col2.3%22));%0A    return rows;%0A  %7D%0A%0A  private static Header createHeader(Table table) %7B%0A    Header header = new Header();%0A    header.insertTable(table);%0A    return header;%0A  %7D%0A%7D%0A

Add example that uses P-Store Java API