Inflation rocked the U.S. economy in 2022. Rising prices across the board led to higher costs for consumer products. But one company's cost is another's revenue, and in the cases of rising commodity, energy, and agricultural prices, plenty of sectors benefited from these trends last year.

The industrial sector is a good hunting ground for stocks that will benefit from rising inflation, specifically with railroads and defense contractors. Here is one railroad and one defense contractor with durable earnings streams to buy in February.

1. Lockheed Martin: one reliable customer

Lockheed Martin (LMT -0.88%) has been a mainstay of the defense industry for decades, becoming one of the largest customers for the U.S. government and its allies. It supplies missiles, helicopters, satellite systems, fighter jets, and many other products for war departments. Some of the company's revenue comes from cost-plus contracting, which gives contractors like Lockheed Martin a guaranteed return on projects. These kinds of contracts are part of the reason why the company can ride through periods when wages and input costs are rising quickly, as is happening today. And even if cost-plus contracting goes away, Lockheed is still the sole supplier for many weapons systems like the cutting-edge F-35 fighter jet. Regardless of the contract structure, Lockheed will likely be a monopoly supplier to the U.S. government for decades to come.

With governments -- especially the U.S. government -- always wanting the latest in defense/war technologies, Lockheed has an incredibly steady and predictable business. Last year, it generated $66 billion in sales and $6.1 billion in free cash flow. More importantly, its backlog grew 11% year over year to $150 billion, a lot of which has been driven by countries wanting to increase their defense spending post the Russian invasion of Ukraine. For example, Finland signed a $9.4 billion deal for the new F-35 fighter jet last year, which will create an earnings stream for many years as the aircraft is deployed and maintained.

Management takes this steady cash flow and returns it to shareholders through dividends and share buybacks. Over the last 10 years, Lockheed's dividend per share is up 165%, while shares outstanding are down 21%, and its dividend is currently yielding 2.60%. If dividend growth and buybacks continue for the next few decades, shareholders of Lockheed stock will achieve solid long-term returns.

2. Union Pacific Corporation: a durable railroad operator

Railroad company Union Pacific (UNP -0.89%) operates in a different industry from Lockheed Martin but actually has similar competitive advantages helping it consistently generate profits. As one of the only railroad operators throughout the western half of the United States, companies that want to ship items by rail have no choice but to use Union Pacific's routes. That allows the company to earn steady profits regardless of its input costs, as it can just pass them on to customers.

Over the last 10 years, Union Pacific has grown its free cash flow by 124%, hitting $5.7 billion over the last 12 months. Like Lockheed, Union Pacific consistently returns cash to shareholders in both dividends and repurchases. The dividend per share is up 280%, and shares outstanding are down 34.5% in the last 10 years. Investors currently get a 2.5% dividend yield each year for holding the stock, indicating to me that shares are inexpensive at the moment.

With urban areas spaced widely across a large land mass, railroads have been a shipping mainstay in the United States for over 100 years. I would bet that they will likely stick around for at least another few decades, if not much longer, as the geography of the West Coast is not changing anytime soon. That bodes well for investors looking to buy Union Pacific stock and hold on for many years.