driver-legacy/src/main/com/mongodb/DB.java
public Set<String> getCollectionNames() {
        List<String> collectionNames =
                new MongoIterableImpl<DBObject>(null, executor, ReadConcern.DEFAULT, primary(),
                        mongo.getMongoClientOptions().getRetryReads()) {
                    @Override
                    public ReadOperation<BatchCursor<DBObject>> asReadOperation() {
                        return new ListCollectionsOperation<DBObject>(name, commandCodec)
                                .nameOnly(true);
                    }
                }.map(new Function<DBObject, String>() {
                            @Override
                            public String apply(final DBObject result) {
                                return (String) result.get("name");
                            }
                        }).into(new ArrayList<String>());
        Collections.sort(collectionNames);
        return new LinkedHashSet<String>(collectionNames);
    }
public Set<String> getCollectionNames() {
        List<String> collectionNames =
                new MongoIterableImpl<DBObject>(null, executor, ReadConcern.DEFAULT, primary(),
                        mongo.getMongoClientOptions().getRetryReads()) {
                    @Override
                    public ReadOperation<BatchCursor<DBObject>> asReadOperation() {
                        return new ListCollectionsOperation<DBObject>(name, commandCodec)
                                .nameOnly(true);
                    }
                }.map(new Function<DBObject, String>() {
                            @Override
                            public String apply(final DBObject result) {
                                return (String) result.get("name");
                            }
                        }).into(new ArrayList<String>());
        Collections.sort(collectionNames);
        return new LinkedHashSet<String>(collectionNames);
    }
public Set < String > getCollectionNames ( ) { List < String > collectionNames = new MongoIterableImpl < DBObject > ( null , executor , ReadConcern . DEFAULT , primary ( ) , mongo . getMongoClientOptions ( ) . getRetryReads ( ) ) { @ Override public ReadOperation < BatchCursor < DBObject > > asReadOperation ( ) { return new ListCollectionsOperation < DBObject > ( name , commandCodec ) . nameOnly ( true ) ; } } . map ( new Function < DBObject , String > ( ) { @ Override public String apply ( final DBObject result ) { return ( String ) result . get ( "name" ) ; } } ) . into ( new ArrayList < String > ( ) ) ; Collections . sort ( collectionNames ) ; return new LinkedHashSet < String > ( collectionNames ) ; }
Returns a set containing the names of all collections in this database.

@return the names of collections in this database
@throws MongoException if the operation failed
@mongodb.driver.manual reference/method/db.getCollectionNames/ getCollectionNames()
Returns a set containing the names of all collections in this database .