Yes it is safe. But during rush hour when trains are packed girls were complaining of frotteurs ( I probably misspelled that) or people who get sexual stimulation from dry humping unwilling women. So during rush hour the first couple of cars of the trains or subways are reserved for women, but only during rush hour in the morning. But you get complaints of this in many places other than Japan, in fact everywhere there is mass transit and tightly pact people. A definition of frotteur can be found below.
Now to the moderators who love to hand out infractions: "dry hump" May not be a family friendly. But it is the best way I can think to describe a frotteur. The term is in no way demeaning to the women who experience such an assault as it is a characteristic of the sickos who would do such a thing.