http://en.wikipedia.org/wiki/Replicator_(Star_Trek)
Theory
A replicator works by rearranging
subatomic particles, which are abundant everywhere in the
universe, to form
molecules and arrange those molecules to form the object. For example, to create a
pork chop, the replicator would first form atoms of carbon, hydrogen, nitrogen, etc., then arrange them into amino acids, proteins, and cells, and assemble the particles into the form of a pork chop.
This process requires the destructive conversion of bulk matter into energy and its subsequent reformation into a pre-scanned matter pattern. In principle, this is similar to the
transporter, but on a smaller scale. However, unlike transporters, which duplicate matter at the quantum level, replicators must be capable of a large number of different materials on demand. If patterns were to be stored at the quantum level, an impossible amount of data storage (or a set of original copies of the materials) would be required. To resolve this, patterns are stored in memory at the molecular level.