China has been awarded a contract by the Indonesian government to build a railway across the country, fending off competition from Japan who were originally the favorites to win the bid.