Another question: are there buses or trains around 5 a.m. that go to
the airport from the city center?
Important note: check carefully what is the terminal you are flying from. It really matters!
There are local trains from Renfe running from the city center to the airport of El Prat de Llobregat. You can find the timetables in: http://www.renfe.com/EN/viajeros/cercanias/barcelona/index.html (in English).
What I would do is to get the train from "Passeig de Gràcia", which is nearby Plaça Catalunya. Its price is around 2 euros.
The first one passing by Passeig de Gràcia is at 5.08 and you arrive in Terminal 2 (the old one) at 5.30. From there you can get a shuttle bus (for free) that drives you to Terminal 1 (where most of the companies fly from). All together, you can make it to your terminal in around 40 minutes.
However, it may be better to get the Aerobús, which is a bus going directly to Terminal 1. You can get the timetables from http://www.aerobusbcn.com/en/timetable (in English). A single ticket is currently 5.90 euros. It is a bit more expensive but drives you to your terminal in around 20 minutes.