Reputation: 1827
I have started playing around with Berkeley DB. This one is really interesting, but I am facing one problem. While creating the Environment we create it like this -
Environment env = new Environment(new File("./bdb"), envConfig);
It initially threw an exception saying "bdb" location was not found. I created the location and it all worked.
My question is how would I set up berkeley DB to create this directory for me if it does not exist. I actually checked at the config method SetAllowCreate(boolean flag) .. but its functionality is different.
Any help would be appreciated. Thanks.
Upvotes: 4
Views: 956
Reputation: 131
You can do -
File file = new File("file path goes here");
// Either the file exists or mkdirs is successful
if (file.exists() || file.mkdirs()) {
Environment env = new Environment(file, envConfig);
}
Upvotes: 2
Reputation: 1827
I actually ended up doing something like this (not sure whether it is right solution but it works)
boolean x = new file("./bdb.data").mkdir();
Environment env = new Environment(new File("./bdb"), envConfig);
Upvotes: 1