i agree largely with what people have said here. in addition:
1) the company you keep - if you're spending time with guys that aren't committed to purity, then it is going to be much more difficult to near impossible. when you're resolved to being pure, and you aren't being pressured to jeopardize that, it's much easier.
i cannot underscore that first point enough. : )
2) momentum - for me, it's become a way of life, and there's no real consideration given to trading in my obedience--and i would hate the notion of "starting over", considering i've been at this for awhile now.
when you've resolved to accomplish something with God's help, and view yourself through the lens of our Creator, you stop viewing these choices as ones you have to make on your own, with our own power, and for insignificant reasons.
i am constantly reminding myself that my life is richer, more blessed trusting God and seeking His best for me, rather than whatever reward or fun that my rebelliousness can get for me.