(Adds details, table, comment, byline)

By Gertrude Chavez-Dreyfuss

July 15 (Reuters) - Speculators boosted their net long position on the U.S. dollar this week, raising it to the highest level since early June, as the currency benefited from a recent round of upbeat U.S. economic data.

The dollar also got a boost from safe-haven flows as investors grappled with Britain's surprising vote to leave the European Union.

The value of the dollar's net long position increased to $8.01 billion in the week ended July 12, from $4.18 billion the previous week, according to Reuters calculations and data from the Commodity Futures Trading Commission released on Friday.

It was the ninth straight week that the dollar posted a net long position.

A much stronger-than-expected U.S. non-farm payrolls for June, which came out last week, helped propel the greenback. While that report did not exactly persuade the Federal Reserve to increase the pace of U.S. rate hikes, it nonetheless cemented the view that the U.S. economy is growing at a much steadier pace than the rest of the world.

Another rate increase by the Fed this year is not exactly a long shot, analysts said.

"Last week's above-consensus U.S. labor market report for June confirms that a Fed rate hike by year-end may not be completely ruled out, especially if expectations of contagion from the June's UK vote rapidly dissipate," said Samarjit Shankar, head of iFlow and quant strategies at BNY Mellon in Boston.

Since the beginning of May, the dollar has gained roughly 5.2 percent.

Speculators also raised sterling net shorts to 60,067 in the latest week, the highest since the week of June 7, data showed.

Investors have been short the pound since November last year. Since the Brexit vote, sterling has dropped more than 10 percent against the dollar.

Short-term investors, meanwhile, put on more euro net shorts this week, with contracts rising to 87,660, the largest since February.

Analysts say the euro's exchange rate versus the dollar has yet to fully reflect the impact of the Brexit vote on the EU.

The Reuters calculation for the aggregate U.S. dollar position is derived from net positions of International Monetary Market speculators in the yen, euro, sterling, Swiss franc and Canadian and Australian dollars.

Japanese Yen (Contracts of 12,500,000 yen)

12 Jul 2016 Prior week

week Long 85,364 87,037 Short 37,819 23,469 Net 47,545 63,568

EURO (Contracts of 125,000 euros)

12 Jul 2016 Prior week

week Long 107,635 112,011 Short 195,295 187,338 Net -87,660 -75,327

POUND STERLING (Contracts of 62,500 pounds sterling)

12 Jul 2016 Prior week

week Long 39,999 45,746 Short 100,066 94,777 Net -60,067 -49,031

SWISS FRANC (Contracts of 125,000 Swiss francs)

12 Jul 2016 Prior week

week Long 23,330 22,474 Short 16,612 13,796 Net 6,718 8,678

CANADIAN DOLLAR (Contracts of 100,000 Canadian dollars)

12 Jul 2016 Prior week

week Long 39,963 41,031 Short 22,788 29,514 Net 17,175 11,517

AUSTRALIAN DOLLAR (Contracts of 100,000 Aussie dollars)

12 Jul 2016 Prior week

week Long 45,938 33,794 Short 29,722 28,891 Net 16,216 4,903

MEXICAN PESO (Contracts of 500,000 pesos)

12 Jul 2016 Prior week

week Long 28,648 24,238 Short 65,820 69,095 Net -37,172 -44,857

NEW ZEALAND DOLLAR (Contracts of 100,000 New Zealand dollars)

12 Jul 2016 Prior week

week Long 31,694 30,606 Short 30,683 32,009 Net 1,011 -1,403

(Reporting by Gertrude Chavez-Dreyfuss; Editing by Chizu Nomiyama and Tom Brown) ((gertrude.chavez@thomsonreuters.com; 646-223-6322; Reuters Messaging: rm://gertrude.chavez.reuters.com@reuters.net))