performance – Write billions of lines in a text file in java

I'm trying to write billions of lines of strings into a file. It works for up to 40 million rows, but generates the "java.nio.BufferOverflowException" error for 400 million rows. I also think that my solution is slow because it takes 45 seconds to write 40 million lines. Below the code.

public static void main (String[] args) throws FileNotFoundException, IOException {

byte[] buffer = "Help I'm stuck in a makeshift cookie factory  n" .getBytes ();
int number_of_lines = 400000000;

FileChannel rwChannel = new RandomAccessFile ("textfile.txt", "rw"). GetChannel ();
ByteBuffer wrBuf = (FileChannel.MapMode.READ_WRITE, 0, buffer.length * number_of_lines);
for (int i = 0; i <number_of_lines; i ++) {
wrBuf.put (buffer);
rwChannel.close ();

How can I be faster if possible and write more than 2 billion string lines?

Trump's speech in prime time on the government's closure

President Donald Trump will hold court in court tonight as he delivers the speech of the Oval Office of

hope to convince the American public and skeptical lawmakers that there is a crisis on the southern border. latest avant-garde news

His goal: to get billions of dollars of funds to build the "big, beautiful" wall he promised in a context of partial closure of the government that has no end.
Read more


How can Google achieve a very fast recommendation algorithm with billions of data?

I'm talking about YouTube. There should be hundreds of queries to create a good algorithm like this, but how do their servers respond to this blazing speed, given the billions of data to calculate?

Crypto market down, but trade generates billions of dollars in revenue

To find out more about Crypto Currency Training news Crypto trading signals and automated trading software join the indicated telegram channel


Join –…

The cryptocurrency market struggled in 2018 and lost more than 75% from its peak in January. Nevertheless, many stock exchanges have generated billions of dollars in revenue, according to recent information.

Exchanges with the biggest income
Although the market collapsed last year, many still made big gains. In particular the exchanges, and Coinbase Inc., among others, predicts an annual turnover of nearly 1.3 billion, according to Bloomberg. Earlier this month, the value of Coinbase reached $ 8 billion, which means that Coinbase is one of the most valuable startups in the world. Even more surprising, this valuation is five times higher than last year. The forecast business figure of $ 1.3 billion in the 2018 business figure comes from the commission of its trading platform, as well as gains and losses from the company's encrypted holdings. ;business.

Coinbase is not the only market to generate big profits. Binance, the largest cryptocurrency exchange in the world, posted a profit of $ 7.5 million in the first quarter and more than $ 200 million in the second quarter of 2018, according to an article published by LinkedIn Binance, Changpeng Zhao, a few months ago. He declares:

Ledger Nano S – The secure hardware portfolio
"Binance is the largest cryptocurrency exchange in the world. In the first three months of its launch, profits reached $ 7,500,000. In the second quarter, profits totaled $ 200,000,000. The 3rd quarter is still in progress and should continue to grow. Any country that can attract Binance to open a branch on its site will receive a nice tax income. "

Upbit and Bithumb, two of the largest stock exchanges in South Korea, reportedly had a monthly turnover of $ 100 million in early 2018, mainly in transaction and withdrawal fees.

Why do stock markets make so much money?
A few weeks ago, Toshi Times recounted how Coinbase had negotiated an $ 8 billion valuation and became, for this reason, the most expensive startup in the United States. Revenues come from fees and commissions for most exchanges, and Bloomberg's Julie Verhage explained where Coinbase's revenue streams came from:

"The company's sales of $ 1.3 billion in 2018 come from commissions on transactions on its platform, as well as gains and losses on its cryptographic holdings. As the company examines several internal measures of the turnover, the exact figures may vary,