A BAM file (.bam) is the binary version of a SAM file.
A SAM file (.sam) is a tab-delimited text file that contains sequence
alignment data. These formats are described on the SAM Tools web site:
With 'view' option of samtools, a bam file can be translated into
viewable text .sam form.
SAM File Format for details.