Separate lines in a single '|' separated line

Hi

I have a file with contents like

china
india
france
japan
italy
germany
.
.
.
.
etc....

I want the output as

china|india|france|japan|italy|germany|.|.|.

How to achieve this ?

one way

tr -s '\n' '|' < inputfile | sed 's/|$//' > newfile

Another:

paste -sd\| file

Hope this should work !!!!!!!!!!!!!!!!!!!!!!!

AWk:

cat filename | awk '{printf "%s|",$0}'

or more simpler one using tr command

cat filename | tr '\n' '|'

Regards,
aajan