How can you stay friend with your ex boyfriend?

It is difficult if he broke up with you. It takes lots of energy to stay in that relationship