source: main/trunk/greenstone2/common-src/src/jdbmedit/JdbKeys.java@ 21402

Last change on this file since 21402 was 21402, checked in by davidb, 14 years ago

Refactoring of class to use API

File size: 1.9 KB
Line 
1/**********************************************************************
2 *
3 * JdbKeys.java --
4 * A component of the Greenstone digital library software
5 * from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * Copyright (C) 2009 The New Zealand Digital Library Project
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 **********************************************************************/
25
26import java.io.IOException;
27import java.util.Properties;
28import java.util.ArrayList;
29
30import jdbm.RecordManager;
31import jdbm.RecordManagerFactory;
32import jdbm.helper.FastIterator;
33import jdbm.htree.HTree;
34
35public class JdbKeys
36{
37 public static void print_usage()
38 {
39 System.err.println("Usage: java JdbKeys database-name");
40 System.exit(-1);
41 }
42
43
44 public static void main(String[] args)
45 {
46 if (args.length != 1) {
47 print_usage();
48 }
49
50 String dbname = args[0];
51
52 try {
53
54 JdbmAPI jdbm_api = new JdbmAPI(dbname,true);
55
56 ArrayList keys = jdbm_api.get_keys();
57
58 int keys_len = keys.size();
59 for (int i=0; i<keys_len; i++) {
60 String key = (String) keys.get(i);
61 System.out.println(key);
62 }
63
64 jdbm_api.close();
65 }
66 catch (IOException e) {
67 e.printStackTrace();
68 }
69 }
70
71}
Note: See TracBrowser for help on using the repository browser.