code: public static DocumentStore getInstance(File location, KeyProvider provider) throws DocumentStoreNotOpenedException {
          try {
              synchronized (documentStores) {
                  DocumentStore ds = documentStores.get(location);
                  // See if the file exists already, so we can raise the right event.
                  // SQLDatabaseFactory.openOrCreateSQLDatabase will create directories and file if
                  // required.
                  boolean created = !location.exists();
                  if (ds == null) {
                      ds = new DocumentStore(location, provider);
                      documentStores.put(location, ds);
                      if (created) {
                          eventBus.post(new DocumentStoreCreated(ds.databaseName));
                      }
                      eventBus.post(new DocumentStoreOpened(ds.databaseName));
                  }
                  return ds;
              }
          }
          catch (IOException e) {
              throw new DocumentStoreNotOpenedException("Database not found: " + location, e);
          } catch (SQLException e) {
              // thrown during schema upgrades, etc
              throw new DocumentStoreNotOpenedException("Database not initialized correctly: " + location, e);
          } catch (IllegalArgumentException e) {
              // thrown by SQLDatabaseFactory if directory is not writable
              throw new DocumentStoreNotOpenedException("Database location not accessible: " + location, e);
          } catch (DocumentStoreNotOpenedException e) {
              throw e;
          } catch (DocumentStoreException e) {
              throw new DocumentStoreNotOpenedException("Datastore not initialized correctly: " + location, e);
          }
      }
docs: <p>
  Get an instance of an existing or newly created store.
  </p>
  <p>
  If encryption is enabled for this platform, passing a {@link KeyProvider} containing a non-null
  key will open or create an encrypted database. If opening a database, the key used to
  create the database must be used. If encryption is not enabled for this platform, returning
  a non-null key will result in an exception.
  </p>
  @param location The location on the file system where the underlying files should be stored.
  Must be a directory.
  @param provider KeyProvider object. Use a {@link NullKeyProvider} if the database shouldn't
  be encrypted.
  @return An existing or newly created store.
  @throws DocumentStoreNotOpenedException if the database located at {@code location} cannot be
  opened (if it already exists) or created.