public synchronized void saveAs(BufferFile outFile, boolean associateWithNewFile,
			TaskMonitor monitor) throws IOException, CancelledException {

		checkIsClosed();

		if (txStarted) {
			throw new AssertException("Can't save during transaction");
		}

		try {
			long txId = startTransaction();
			boolean addedTx = false;
			try {
				// About to create copy of existing file - assign new databaseId
				if (bufferMgr.getSourceFile() != null) {
					initDatabaseId();
				}
				masterTable.flush();
			}
			finally {
				addedTx = endTransaction(txId, true); // saved file may be corrupt on IOException
			}

			bufferMgr.saveAs(outFile, associateWithNewFile, monitor);

			if (addedTx && !associateWithNewFile) {
				// Restore state and original databaseId
				undo();
				readDatabaseId();
			}
		}
		finally {
			cacheChangedState();
		}
	}
Save the database to the specified buffer file.
@param outFile buffer file open for writing
@param associateWithNewFile if true the outFile will be associated with this DBHandle as the 
current source file, if false no change will be made to this DBHandle's state and the outFile
will be written and set as read-only.  The caller is responsbile for disposing the outFile if 
this parameter is false.
@param monitor progress monitor
@throws IOException if IO error occurs
@throws CancelledException if monitor cancels operation
Ghidra/Framework/DB/src/main/java/db/DBHandle.java