If your opponent throws a knee while not in clinch a good way to stop it is to extend your arm (jab) to their chest. If you lean slightly into it your arm should reach longer than their knee. You may as well hit the chin instead of the chest.
If you are locked in the clinch you can try to throw your opponent off balance as soon as they lift their leg to throw the knee. You do this by rotating them in the direction of their standing leg. (If they throw right knee, you rotate to your right.) Moving their weight beyond their standing leg you may get the possibility of throwing them or to counter with a knee yourself (Right knee). This technique needs some practice because it's usually hard to see you opponents leg when locked in the clinch. You'll have to learn to sense it mostly from how their weight shifts.
Edit: Finally found a Video that shows the throw as a defense against a knee in the clinch: http://youtu.be/Co-rINOoMn8?t=5m15s and http://youtu.be/Co-rINOoMn8?t=18m55s