Is there any function to import and export all collections of mongodb database using java driver.? like there is mongodump
and mongorestore
using command prompt.
The short answer is no. These commands can be invoked only from command line. You might consider to fetch all the data from all collections but its expected to be slow.
You can read a discussion around this here.