The maximum document size in mongoDB is 16MB. To store documents larger than the maximum size (16 MB), MongoDB provides the GridFS API.
How GridFS handles data more than 16MB
Instead of storing a file in a single document, GridFS divides a file into parts, called chunks. Each chunk stored as a single document.
GridFS uses two collections to store files. One to store meta data about chunks, and other to store chunks. When you query a GridFS store for a file, the driver or client will reassemble the chunks as needed.
After running above java program, it creates two collections, one for to store chunks and other to store metadata.