Ticket #716: Delete1.java

File Delete1.java, 972 bytes (added by Aakash, 8 years ago)

Java implementation of delete1.py

Line 
1package org.xapian.examples;
2
3import org.xapian.WritableDatabase;
4import org.xapian.XapianConstants;
5
6public class Delete1 {
7
8 // Command line args - dbpath identifiers...
9 public static void main(String[] args)
10 {
11 if(args.length < 2)
12 {
13 System.out.println("Insufficient number of arguments (should be dbpath identifiers...)");
14 return;
15 }
16 deleteDocs(args[0], args);
17 }
18
19 public static void deleteDocs(String dbpath, String[] identifierArgs)
20 {
21 // Open the database we're going to be deleting from.
22 WritableDatabase db = new WritableDatabase(dbpath, XapianConstants.DB_OPEN);
23
24 //identifiers start from index 1
25 for(int i=1; i < identifierArgs.length; i++)
26 {
27 String idterm = "Q" + identifierArgs[i];
28 db.deleteDocument(idterm);
29 }
30
31 // Commit to delete documents from disk
32 db.commit();
33 }
34}