I am searching how to create a file and write the results of the program.
I am working in MongoDB with Java and I tried to write a program to put my results in a folder (in My Documents ) in my PC but it did not work that way.
mongoClient = new MongoClient("localhost", 27017);
db = mongoClient.getDB("behaviourDB_areas");
DBCollection cEvent = db.getCollection("events_searchingTasks");
cursorEvents = cEvent.find();
File directory = new File("C://USER//documents//dirname");
directory.mkdir();
int count = 0;
if (cursorEvents.hasNext()){
while(cursorEvents.hasNext()){
count++;
System.out.println("num(" + count + "): " + cursorEvents.next().get("type").toString());
}
}
Suggestions appreciated.