I feel sorry to say that, but the other answers are simply not true, or outdated.
You cannot ride on a sidewalk, unless you meet one of the following criteria:
The lane is 3 meters or wider
Age less than 13, or 70 or older
There is a road sign that signifies you can ride on the lane
Inevitable cases in favor of safety (e.g. so many parked cars on the road preventing you from riding, etc...)
Otherwise, it is illegal to ride on the sidewalk and you might be put in jail at the worse case possible.
The detailed explanation is here, written in Japanese.
Other violated actions include the ignorance of a traffic light, riding while drunk, using a smartphone, earhub, and/or umbrella while riding, riding on the right side, etc...
Also note that pedestrians should always have a priority to walk and pass through; you must keep waiting for them to pass through before starting to ride.
The awful cyclists manners have been frequently said everywhere, but much like many other cases in Japan (e.g. smoking while walking), the chance of being stopped/caught by police or any local authorities is close to zero. That's why many people still ride on the sidewalk without ever caring about pedestrians around them.
But still, don't imitate the behavior of others; observe the local regulations instead. Many people are frustrated with evil cyclists.
As to the original question - Is cycling in Tokyo safe? - it is generally safe. However, you should always lock your bicycle when you park it - otherwise it gets stolen easily.