The hosts text file contains a database of domain names and their corresponding ip. The contents of the file are controlled by the user. A request to this file has higher priority than a request to DNS servers.
By writing the domain and ip in this file, your browser will look for the domain on this ip.
Thus you can, for example, set up a site on a new hosting without redirecting the domain itself, or while the domain is not yet purchased.
The file has a different location on different operating systems:
|Windows 95, 98, Me||%windir%||c:\windows\hosts|
|Windows 2000, XP, Vista, 7||%SystemRoot%|
(can be overridden in the registry)
|Mac OS X||/private/etc/hosts|