Fresh corn of the cob can actually freeze very well and keep for a year.
If you can buy it fresh at the local farmer’s market, just pack it immediately into freezer bags with the husk and silk intact. When you unfreeze, it will be crisp and succulent.
For store-bought corn that is days or weeks old, husk it and then boil briefly in water. Boil small ears for 7 minutes, medium ears for 9 minutes, and large ears for 11 minutes.