Not eating unhealthy food has a lot more to do with what you do eat than what you don't. You can either fight temptation every single time you have the option to eat something unhealthy, but there is a better way and that consists of 2 things:
1) Proactively eating healthy food first
This is why I say it's more about what you eat than what you don't. The key here is response time. If your diet was a house, your apetite would be your house on fire and the sooner the fire department comes, the less damage is done. The same applies to eating healthy and that is why you need to be proactive. Plan on being hungry and keep your diet solution simple.
When you start to think about icecream or cheeseburgers and can't get it off your mind, immediately go eat a salad, a piece of fruit, or at the very least drink a glass or two of water. After you eat it, it doesnt matter how good or bad it tasted, all you will remember is how full or hungry you are. Ironically, unhealthy food often spends hours in your digestive system and can be uncomfortable to digest, yet that is what we prefer only if for a few seconds of a good taste. Healthy food, on the other hand, helps our digestive system and feels good for hours after we've eaten it. On some level, you know this, so this step is merely the practical application of that knowledge--skip the mental wrestling match over how good that donut would taste and skip to having healthy food in your stomach as fast as possible, and you'll find you can conquer your cravings much easier.
2) Change the palette of what you feel like eating
This often comes with weeks or even months of eating better and it's all about our relationship with food. If you're like me, the problem is when we believe the purpose of food is to taste good, not to nourish us. You need to start eating healthy first and eventually you'll start to find you prefer healthy food anyways. The reason this happens is because over time, we subconsciously realize that the good feeling we have after eating healthy food is more desirable than a few moments of pleasure.
Have you ever gotten sick after eating something, and later find that the smell or taste of a similar essence will make you nauseous? (For me, it is artificial strawberry thanks to strawberry Smirnoff... I'll let you imagine the circumstances). Our subconscious remembers what it thinks is good and bad for us and tailors our palette to eat more "good" things and avoid the "bad" ones. Obviously, the pure energy of sugary or fatty foods bode well with our brain's survival mechanism, but we know better over the long run.
To set this subconscious, biological change in motion, you must first change your attitude about food. Instead of thinking about how good it tastes all the time, you want to break down what you're really getting when you dig in. This is a skill that takes time to learn, but eventually it will help you choose more quality food. Start by breaking it down into the major ingredients of what's in it... if you don't know and have access to the nutritional information, the ingredients are listed in order of which is used the most... 95% or more of what the food is can usually be found in the first 5 ingredients listed.
Now, instead of seeing a juicy fast-food cheeseburger, you're getting processed white flour bun, processed milk fat/cheese, sodium-heavy condiments, and a processed soy-meat patty. The only valuable part in terms of nutrition is the onions and lettuce. As soon as I finish eating it, I'm going to be absorbing a whole lot of empty carbohydrates and grease, some of which is going to drain itself through my intestines and into the toilet. Mmm, that sounds sooo tempting, doesn't it? On the other hand, I could choose a salad. When I do that, I just imagine all that leafy greens, fruits, vegetables, and nuts being absorbed into my system and it's hard to not want that more than the cheeseburger. I'm not saying cheeseburgers wouldn't taste better... but by changing my attitude about what food's purpose is, eventually it's easier to choose healthy options and that habit will make your diet very doable.
It's a matter of momentum and the first few weeks are a lot of work, but once you're consistently ingesting high quality, nutritious foods, you'll find it's even easier not to feel like you just gotta have that junkfood you see on TV.