client/ftpd/src/se/lu/thep/coreftpd/common/DatabaseFile.java

Code
Comments
Other
Rev Date Author Line
741 10 Oct 06 olle 1 /*
1652 22 May 07 gregory 2  $Id$
741 10 Oct 06 olle 3
1916 31 Aug 07 jari 4  Copyright (C) 2006 Olle Mansson
1916 31 Aug 07 jari 5  Copyright (C) 2007 Gregory Vincic
741 10 Oct 06 olle 6
1652 22 May 07 gregory 7  This file is part of Proteios.
1652 22 May 07 gregory 8  Available at http://www.proteios.org/
741 10 Oct 06 olle 9
1652 22 May 07 gregory 10  Proteios is free software; you can redistribute it and/or modify it
1652 22 May 07 gregory 11  under the terms of the GNU General Public License as published by
1652 22 May 07 gregory 12  the Free Software Foundation; either version 2 of the License, or
1652 22 May 07 gregory 13  (at your option) any later version.
741 10 Oct 06 olle 14
1652 22 May 07 gregory 15  Proteios is distributed in the hope that it will be useful, but
1652 22 May 07 gregory 16  WITHOUT ANY WARRANTY; without even the implied warranty of
1652 22 May 07 gregory 17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1652 22 May 07 gregory 18  General Public License for more details.
741 10 Oct 06 olle 19
1652 22 May 07 gregory 20  You should have received a copy of the GNU General Public License
1652 22 May 07 gregory 21  along with this program; if not, write to the Free Software
1652 22 May 07 gregory 22  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1652 22 May 07 gregory 23  02111-1307, USA.
1652 22 May 07 gregory 24  */
741 10 Oct 06 olle 25
741 10 Oct 06 olle 26 //  Xerver Free Web Server
741 10 Oct 06 olle 27 //  Copyright (C) 2002-2005 Omid Rouhani
741 10 Oct 06 olle 28 //
741 10 Oct 06 olle 29 //
741 10 Oct 06 olle 30 //  This program is free software; you can redistribute it and/or
741 10 Oct 06 olle 31 //  modify it under the terms of the GNU General Public License
741 10 Oct 06 olle 32 //  as published by the Free Software Foundation; either version 2
741 10 Oct 06 olle 33 //  of the License, or (at your option) any later version.
741 10 Oct 06 olle 34 //
741 10 Oct 06 olle 35 //  This program is distributed in the hope that it will be useful,
741 10 Oct 06 olle 36 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
741 10 Oct 06 olle 37 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
741 10 Oct 06 olle 38 //  GNU General Public License for more details.
741 10 Oct 06 olle 39 //
741 10 Oct 06 olle 40 //  You should have received a copy of the GNU General Public License
741 10 Oct 06 olle 41 //  along with this program; if not, write to the Free Software
741 10 Oct 06 olle 42 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
741 10 Oct 06 olle 43 //
741 10 Oct 06 olle 44 //
741 10 Oct 06 olle 45 //  #############################################################
741 10 Oct 06 olle 46 //  ##  YOU CAN CONTACT THE AUTHOR (OMID ROUHANI) AT:          ##
741 10 Oct 06 olle 47 //  ##  HTTP://WWW.JAVASCRIPT.NU/XERVER/                       ##
741 10 Oct 06 olle 48 //  ##                                                         ##
741 10 Oct 06 olle 49 //  ##  IF YOUR SOFTWARE IS NOT RELEASED UNDER THE             ##
741 10 Oct 06 olle 50 //  ##  GNU GENERAL PUBLIC LICENSE (GPL),                      ##
741 10 Oct 06 olle 51 //  ##  PLEASE DO NOT COPY ANYTHING FROM THIS SOURCE CODE!!!   ##
741 10 Oct 06 olle 52 //  ##                                                         ##
741 10 Oct 06 olle 53 //  ##  FOR FULL LICENSE, PLEASE READ "XERVER LICENSE".        ##
741 10 Oct 06 olle 54 //  #############################################################
791 23 Oct 06 olle 55 package se.lu.thep.coreftpd.common;
741 10 Oct 06 olle 56
741 10 Oct 06 olle 57 import java.io.BufferedReader;
741 10 Oct 06 olle 58 import java.io.BufferedWriter;
741 10 Oct 06 olle 59 import java.io.File;
741 10 Oct 06 olle 60 import java.io.FileReader;
741 10 Oct 06 olle 61 import java.io.FileWriter;
741 10 Oct 06 olle 62 import java.io.PrintWriter;
741 10 Oct 06 olle 63
741 10 Oct 06 olle 64 /**
741 10 Oct 06 olle 65  * <B>About this class:</B> <BR>
741 10 Oct 06 olle 66  * A very useful class if you want an application with a settings file which can
741 10 Oct 06 olle 67  * easily be edited, both by a human and by this class. <BR>
741 10 Oct 06 olle 68  * This class can both write to and read from the database (the file). <BR>
741 10 Oct 06 olle 69  * This class can also make basic file operations such as deleting, copying and
741 10 Oct 06 olle 70  * renameing the file.
741 10 Oct 06 olle 71  * 
741 10 Oct 06 olle 72  * @author <a href="http://www.JavaScript.nu/xerver/" TARGET="_top">Omid Rouhani</a>
741 10 Oct 06 olle 73  * @version 1.0
741 10 Oct 06 olle 74  */
1652 22 May 07 gregory 75 final public class DatabaseFile {
741 10 Oct 06 olle 76   private File f_file;
1652 22 May 07 gregory 77
741 10 Oct 06 olle 78   private String s_filePath;
1652 22 May 07 gregory 79
741 10 Oct 06 olle 80   /**
741 10 Oct 06 olle 81    * Lines starting with this character are comments.
741 10 Oct 06 olle 82    */
741 10 Oct 06 olle 83   private char commentChar = ';';
1652 22 May 07 gregory 84
741 10 Oct 06 olle 85   /**
741 10 Oct 06 olle 86    * This is the separator between a name and its value. <BR>
741 10 Oct 06 olle 87    * Example: Name=John Smith
741 10 Oct 06 olle 88    */
741 10 Oct 06 olle 89   private char assignChar = '=';
741 10 Oct 06 olle 90
1652 22 May 07 gregory 91   public DatabaseFile(String argFile) throws Exception {
741 10 Oct 06 olle 92     this(new File(argFile));
741 10 Oct 06 olle 93   }
741 10 Oct 06 olle 94
1652 22 May 07 gregory 95   public DatabaseFile(File argFile) throws Exception {
741 10 Oct 06 olle 96     // if (argFile.exists())
741 10 Oct 06 olle 97     // {
741 10 Oct 06 olle 98     f_file = argFile;
741 10 Oct 06 olle 99     s_filePath = f_file.getPath();
741 10 Oct 06 olle 100     // }
741 10 Oct 06 olle 101     // else
741 10 Oct 06 olle 102     // {
741 10 Oct 06 olle 103     // new Exception("File does not exists when creating a new
741 10 Oct 06 olle 104     // DatabaseFile!");
741 10 Oct 06 olle 105     // }
741 10 Oct 06 olle 106   }
741 10 Oct 06 olle 107
741 10 Oct 06 olle 108   /**
741 10 Oct 06 olle 109    * Sets <CODE>assignChar</CODE> (see <CODE>assignChar</CODE>
741 10 Oct 06 olle 110    * documentation).
741 10 Oct 06 olle 111    */
1652 22 May 07 gregory 112   synchronized public void setAssignChar(char argAssign) {
741 10 Oct 06 olle 113     assignChar = argAssign;
741 10 Oct 06 olle 114   }
741 10 Oct 06 olle 115
741 10 Oct 06 olle 116   /**
741 10 Oct 06 olle 117    * Sets <CODE>commentChar</CODE> (see <CODE>commentChar</CODE>
741 10 Oct 06 olle 118    * documentation).
741 10 Oct 06 olle 119    */
1652 22 May 07 gregory 120   synchronized public void setCommentChar(char argComment) {
741 10 Oct 06 olle 121     commentChar = argComment;
741 10 Oct 06 olle 122   }
741 10 Oct 06 olle 123
741 10 Oct 06 olle 124   /**
741 10 Oct 06 olle 125    * Removes a value from the database.
741 10 Oct 06 olle 126    */
1652 22 May 07 gregory 127   synchronized public boolean removeValue(String name) throws Exception {
741 10 Oct 06 olle 128     return updateValue(name, null);
741 10 Oct 06 olle 129   }
741 10 Oct 06 olle 130
741 10 Oct 06 olle 131   /**
741 10 Oct 06 olle 132    * Updates the value of this variable. <BR>
741 10 Oct 06 olle 133    * IMPORTANT: If "<CODE>value</CODE>" is <CODE>null</CODE>, then it
741 10 Oct 06 olle 134    * means that we shall REMOVE "<CODE>name</CODE>" from the file!
741 10 Oct 06 olle 135    * 
741 10 Oct 06 olle 136    * @return Returns true iff "name" exists in file and the value has been
741 10 Oct 06 olle 137    *         replaced with "value". Returns false iff "name" does not exists
741 10 Oct 06 olle 138    *         in file.
741 10 Oct 06 olle 139    */
741 10 Oct 06 olle 140   synchronized public boolean updateValue(String name, String value)
1652 22 May 07 gregory 141       throws Exception {
741 10 Oct 06 olle 142     boolean retValue = false;
741 10 Oct 06 olle 143     File f_tmpFile = File.createTempFile("Xerver", ".tmp");
741 10 Oct 06 olle 144     BufferedReader br_userFile = new BufferedReader(new FileReader(f_file));
741 10 Oct 06 olle 145     PrintWriter bw_newFile = new PrintWriter(new BufferedWriter(
1652 22 May 07 gregory 146         new FileWriter(f_tmpFile)));
741 10 Oct 06 olle 147     String lineNotModified, tmpLine;
1652 22 May 07 gregory 148     while ((lineNotModified = tmpLine = br_userFile.readLine()) != null) {
741 10 Oct 06 olle 149       tmpLine.trim();
1652 22 May 07 gregory 150       if (tmpLine.length() > 0) {
1652 22 May 07 gregory 151         if (tmpLine.charAt(0) != commentChar) {
741 10 Oct 06 olle 152           String varName, varValue;
741 10 Oct 06 olle 153           int indexOfValue = tmpLine.indexOf(assignChar);
741 10 Oct 06 olle 154           varName = tmpLine.substring(0, indexOfValue);
741 10 Oct 06 olle 155           varValue = tmpLine.substring(indexOfValue + 1);
1652 22 May 07 gregory 156           if (name.equalsIgnoreCase(varName)) {
741 10 Oct 06 olle 157             retValue = true;
741 10 Oct 06 olle 158             if (value != null) // If we have a value for "name", we
1652 22 May 07 gregory 159               // shall UPDATE name (otherwise
1652 22 May 07 gregory 160               // remove name)
741 10 Oct 06 olle 161               bw_newFile.println(varName + assignChar + value);
741 10 Oct 06 olle 162             // else //Otherwise we don't do anything here, resulting
741 10 Oct 06 olle 163             // that we REMOIVE "name" from the file!
741 10 Oct 06 olle 164             continue; // Don't write "lineNotModified" to file
741 10 Oct 06 olle 165           }
741 10 Oct 06 olle 166         }
741 10 Oct 06 olle 167       }
741 10 Oct 06 olle 168       bw_newFile.println(lineNotModified);
741 10 Oct 06 olle 169     }
741 10 Oct 06 olle 170     // Close everything so file won't be locked by JVM to long
741 10 Oct 06 olle 171     br_userFile.close();
741 10 Oct 06 olle 172     bw_newFile.flush();
741 10 Oct 06 olle 173     bw_newFile.close();
741 10 Oct 06 olle 174     bw_newFile = null;
741 10 Oct 06 olle 175     br_userFile = null;
1652 22 May 07 gregory 176     if (f_file.delete()) {
741 10 Oct 06 olle 177       if (!f_tmpFile.renameTo(f_file)) // On Solaris File.renameTo()
1652 22 May 07 gregory 178       // cannot move a file from one
1652 22 May 07 gregory 179       // file system to another...
741 10 Oct 06 olle 180       {
741 10 Oct 06 olle 181         FileWithCopy.copyFile(f_tmpFile, f_file);
741 10 Oct 06 olle 182       }
741 10 Oct 06 olle 183     }
741 10 Oct 06 olle 184     f_file = new File(s_filePath); // Renew "f_file" for next run...
741 10 Oct 06 olle 185     return retValue;
741 10 Oct 06 olle 186   }
741 10 Oct 06 olle 187
741 10 Oct 06 olle 188   /**
741 10 Oct 06 olle 189    * Add a new empty line to the file.
741 10 Oct 06 olle 190    */
1652 22 May 07 gregory 191   synchronized public void addNewLine() throws Exception {
741 10 Oct 06 olle 192     PrintWriter bw_newFile = new PrintWriter(new BufferedWriter(
1652 22 May 07 gregory 193         new FileWriter(f_file.getAbsolutePath(), true))); // Append
1652 22 May 07 gregory 194     // data... Note:
1652 22 May 07 gregory 195     // we need
1652 22 May 07 gregory 196     // ".getAbsolutePath()")
1652 22 May 07 gregory 197     // becuase
1652 22 May 07 gregory 198     // "FileWriter(File,boolean)"
1652 22 May 07 gregory 199     // only exists
1652 22 May 07 gregory 200     // on Java 1.4
1652 22 May 07 gregory 201     // and above.
1652 22 May 07 gregory 202     // (Without
1652 22 May 07 gregory 203     // this, users
1652 22 May 07 gregory 204     // with older
1652 22 May 07 gregory 205     // Java versions
1652 22 May 07 gregory 206     // would get an
1652 22 May 07 gregory 207     // error during
1652 22 May 07 gregory 208     // runtime).
741 10 Oct 06 olle 209     bw_newFile.println();
741 10 Oct 06 olle 210     bw_newFile.close();
741 10 Oct 06 olle 211     bw_newFile = null;
741 10 Oct 06 olle 212   }
741 10 Oct 06 olle 213
741 10 Oct 06 olle 214   /**
741 10 Oct 06 olle 215    * This adds a new <CODE>name</CODE>/<CODE>value</CODE> couple at the
741 10 Oct 06 olle 216    * end of the file. <B>IMPORTANT:</B> If "name" already exists, a new name
741 10 Oct 06 olle 217    * will be added anyway, resulting in having two (or more) "variables" with
741 10 Oct 06 olle 218    * possibly different values!!! <BR>
741 10 Oct 06 olle 219    * This member shall be used with CARE!! <BR>
741 10 Oct 06 olle 220    * Also, if you use this member, make sure the file's last line ends with a
741 10 Oct 06 olle 221    * newline-character!! <BR>
741 10 Oct 06 olle 222    * Use setValue or updateValue instead to avoid these problems. (or just
741 10 Oct 06 olle 223    * call addNewLine() once before you call this method the very first time
741 10 Oct 06 olle 224    * and you will be safe).
741 10 Oct 06 olle 225    */
741 10 Oct 06 olle 226   synchronized public void addNewValue(String name, String value)
1652 22 May 07 gregory 227       throws Exception {
741 10 Oct 06 olle 228     PrintWriter bw_newFile = new PrintWriter(new BufferedWriter(
1652 22 May 07 gregory 229         new FileWriter(f_file.getAbsolutePath(), true))); // Append
1652 22 May 07 gregory 230     // data... Note:
1652 22 May 07 gregory 231     // we need
1652 22 May 07 gregory 232     // ".getAbsolutePath()")
1652 22 May 07 gregory 233     // becuase
1652 22 May 07 gregory 234     // "FileWriter(File,boolean)"
1652 22 May 07 gregory 235     // only exists
1652 22 May 07 gregory 236     // on Java 1.4
1652 22 May 07 gregory 237     // and above.
1652 22 May 07 gregory 238     // (Without
1652 22 May 07 gregory 239     // this, users
1652 22 May 07 gregory 240     // with older
1652 22 May 07 gregory 241     // Java versions
1652 22 May 07 gregory 242     // would get an
1652 22 May 07 gregory 243     // error during
1652 22 May 07 gregory 244     // runtime).
741 10 Oct 06 olle 245     bw_newFile.println(name + assignChar + value);
741 10 Oct 06 olle 246     bw_newFile.close();
741 10 Oct 06 olle 247     bw_newFile = null;
741 10 Oct 06 olle 248   }
741 10 Oct 06 olle 249
741 10 Oct 06 olle 250   /**
741 10 Oct 06 olle 251    * Add a comment to the end of this file. <BR>
741 10 Oct 06 olle 252    * <B>IMPORTANT:</B> If you use this member, make sure the file's last line
741 10 Oct 06 olle 253    * ends with a newline-character. (or just call addNewLine() once before you
741 10 Oct 06 olle 254    * call this method the very first time and you will be safe).
741 10 Oct 06 olle 255    */
1652 22 May 07 gregory 256   synchronized public void addNewComment(String comment) throws Exception {
741 10 Oct 06 olle 257     PrintWriter bw_newFile = new PrintWriter(new BufferedWriter(
1652 22 May 07 gregory 258         new FileWriter(f_file.getAbsolutePath(), true))); // Append
1652 22 May 07 gregory 259     // data... Note:
1652 22 May 07 gregory 260     // we need
1652 22 May 07 gregory 261     // ".getAbsolutePath()")
1652 22 May 07 gregory 262     // becuase
1652 22 May 07 gregory 263     // "FileWriter(File,boolean)"
1652 22 May 07 gregory 264     // only exists
1652 22 May 07 gregory 265     // on Java 1.4
1652 22 May 07 gregory 266     // and above.
1652 22 May 07 gregory 267     // (Without
1652 22 May 07 gregory 268     // this, users
1652 22 May 07 gregory 269     // with older
1652 22 May 07 gregory 270     // Java versions
1652 22 May 07 gregory 271     // would get an
1652 22 May 07 gregory 272     // error during
1652 22 May 07 gregory 273     // runtime).
741 10 Oct 06 olle 274     bw_newFile.println(commentChar + comment);
741 10 Oct 06 olle 275     bw_newFile.close();
741 10 Oct 06 olle 276     bw_newFile = null;
741 10 Oct 06 olle 277   }
741 10 Oct 06 olle 278
741 10 Oct 06 olle 279   /**
741 10 Oct 06 olle 280    * If <CODE>name</CODE> already exists, update its value- <BR>
741 10 Oct 06 olle 281    * If <CODE>name</CODE> doesn't exists, creates a new "variable" with this
741 10 Oct 06 olle 282    * name/value.
741 10 Oct 06 olle 283    */
741 10 Oct 06 olle 284   synchronized public void setValue(String name, String value)
1652 22 May 07 gregory 285       throws Exception {
741 10 Oct 06 olle 286     // First we try to update the value, if not possible, we add the new
741 10 Oct 06 olle 287     // value
1652 22 May 07 gregory 288     if (!updateValue(name, value)) {
741 10 Oct 06 olle 289       addNewLine();// Add a new line to avoid problems if file does not
1652 22 May 07 gregory 290       // end with a newline-character in the end of the
1652 22 May 07 gregory 291       // last line in the file.
741 10 Oct 06 olle 292       addNewValue(name, value);
741 10 Oct 06 olle 293     }
741 10 Oct 06 olle 294   }
741 10 Oct 06 olle 295
741 10 Oct 06 olle 296   /**
741 10 Oct 06 olle 297    * Returns the value from the variable "name". <BR>
741 10 Oct 06 olle 298    * This means searching the file for a line containing "name=value" and
741 10 Oct 06 olle 299    * returning "value".
741 10 Oct 06 olle 300    */
1652 22 May 07 gregory 301   synchronized public String getValue(String name) throws Exception {
741 10 Oct 06 olle 302     BufferedReader br_userFile = new BufferedReader(new FileReader(f_file));
741 10 Oct 06 olle 303     String retValue = null;
741 10 Oct 06 olle 304     String tmpLine;
1652 22 May 07 gregory 305     while ((tmpLine = br_userFile.readLine()) != null) {
741 10 Oct 06 olle 306       tmpLine.trim();
1652 22 May 07 gregory 307       if (tmpLine.length() > 0) {
1652 22 May 07 gregory 308         if (tmpLine.charAt(0) != commentChar) {
741 10 Oct 06 olle 309           String varName, varValue;
741 10 Oct 06 olle 310           int indexOfValue = tmpLine.indexOf(assignChar);
741 10 Oct 06 olle 311           varName = tmpLine.substring(0, indexOfValue);
741 10 Oct 06 olle 312           varValue = tmpLine.substring(indexOfValue + 1);
1652 22 May 07 gregory 313           if (name.equalsIgnoreCase(varName)) {
741 10 Oct 06 olle 314             retValue = varValue;
741 10 Oct 06 olle 315             break;
741 10 Oct 06 olle 316           }
741 10 Oct 06 olle 317         }
741 10 Oct 06 olle 318       }
741 10 Oct 06 olle 319     }
741 10 Oct 06 olle 320     br_userFile.close();
741 10 Oct 06 olle 321     br_userFile = null;
741 10 Oct 06 olle 322     return retValue; // Value not found
741 10 Oct 06 olle 323   }
741 10 Oct 06 olle 324
741 10 Oct 06 olle 325   /**
741 10 Oct 06 olle 326    * Renames the database file. <BR>
741 10 Oct 06 olle 327    * 
741 10 Oct 06 olle 328    * @return Returns true iff renaming file was successful.
741 10 Oct 06 olle 329    */
1652 22 May 07 gregory 330   synchronized public boolean renameFile(String newPath) {
741 10 Oct 06 olle 331     boolean retValue = f_file.renameTo(new File(newPath));
1652 22 May 07 gregory 332     if (retValue) {
741 10 Oct 06 olle 333       s_filePath = f_file.getPath();
741 10 Oct 06 olle 334     }
741 10 Oct 06 olle 335     return retValue;
741 10 Oct 06 olle 336   }
741 10 Oct 06 olle 337
741 10 Oct 06 olle 338   /**
741 10 Oct 06 olle 339    * Creates a copy of this database file. <BR>
741 10 Oct 06 olle 340    * 
741 10 Oct 06 olle 341    * @return Returns true iff copying file was successful.
741 10 Oct 06 olle 342    */
1652 22 May 07 gregory 343   synchronized public boolean copyFile(String newPath) {
741 10 Oct 06 olle 344     File newFile = new File(newPath);
741 10 Oct 06 olle 345     if (newFile.exists())
741 10 Oct 06 olle 346       return false; // We choose that this method shall not overwrite
1652 22 May 07 gregory 347     // the destination file in case it already exists
741 10 Oct 06 olle 348     return FileWithCopy.copyFile(f_file, newFile);
741 10 Oct 06 olle 349   }
741 10 Oct 06 olle 350
741 10 Oct 06 olle 351   /**
741 10 Oct 06 olle 352    * Deletes the database file. <BR>
741 10 Oct 06 olle 353    * 
741 10 Oct 06 olle 354    * @return Returns true iff deleting file was successful.
741 10 Oct 06 olle 355    */
1652 22 May 07 gregory 356   synchronized public boolean deleteFile() {
741 10 Oct 06 olle 357     return f_file.delete();
741 10 Oct 06 olle 358   }
741 10 Oct 06 olle 359
741 10 Oct 06 olle 360   /**
741 10 Oct 06 olle 361    * @return Returns true iff file exists.
741 10 Oct 06 olle 362    */
1652 22 May 07 gregory 363   synchronized public boolean fileExists() {
741 10 Oct 06 olle 364     return f_file.exists() && !f_file.isDirectory();
741 10 Oct 06 olle 365   }
741 10 Oct 06 olle 366
741 10 Oct 06 olle 367   /**
741 10 Oct 06 olle 368    * Creates this database file. <BR>
741 10 Oct 06 olle 369    * 
741 10 Oct 06 olle 370    * @return Returns true iff creating file was successful.
741 10 Oct 06 olle 371    */
1652 22 May 07 gregory 372   synchronized public boolean createNewFile() {
1652 22 May 07 gregory 373     try {
741 10 Oct 06 olle 374       return f_file.createNewFile();
1652 22 May 07 gregory 375     } catch (Exception e) {
741 10 Oct 06 olle 376       return false; // Don't throw back exception, just return false...
1652 22 May 07 gregory 377       // (For example when file already exists)
741 10 Oct 06 olle 378     }
741 10 Oct 06 olle 379   }
741 10 Oct 06 olle 380
741 10 Oct 06 olle 381   /**
741 10 Oct 06 olle 382    * Run this when you are finished with reading/writing to the database. In
741 10 Oct 06 olle 383    * case the JVM has locked the database file, it will be released after
741 10 Oct 06 olle 384    * this.
741 10 Oct 06 olle 385    */
1652 22 May 07 gregory 386   public void destroy() {
741 10 Oct 06 olle 387     f_file = null;
741 10 Oct 06 olle 388     s_filePath = null;
741 10 Oct 06 olle 389     System.gc(); // If this is not runned the file might be locked by JVM
1652 22 May 07 gregory 390     // until the Garbage Collector (gc) is run. To make sure
1652 22 May 07 gregory 391     // the file is released we must force JVM to run gc.
1652 22 May 07 gregory 392     // However, it might take time to run garbage collector,
1652 22 May 07 gregory 393     // so this is a priority issue.
741 10 Oct 06 olle 394   }
741 10 Oct 06 olle 395 }