.txt文件大小是否有上限? [英] Is there an upper limit on .txt file size?

查看:602
本文介绍了.txt文件大小是否有上限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为圣诞节礼物,我用Java编写了一个小程序来计算素数.我的意图是整夜保留它,计算下一个素数并将其写入.txt文件.早上,我将终止该程序,并将.txt文件带给我的朋友过圣诞节.

As a Christmas gift I have written a small program in Java to calculate primes. My intention was to leave it on all night, calculating the next prime and writing it to a .txt file. In the morning I would kill the program and take the .txt file to my friend for Christmas.

我有什么需要担心的吗?请记住,这是您正在与之交谈的真正的初学者Ziggy,而不是一些检查ASM的聪明错误.

Is there anything I should be worried about? Bear in mind that this is true beginner Ziggy you are talking to, not some smart error checking ASM guy.

编辑更具体地说,由于我将整夜不停地进行素数运算,所以有没有机会遇到某种与内存相关的错误?像是堆压碎堆或猫狗睡在一起吗?

EDIT More specifically, since I will be leaving this program on all night counting primes, is there any chance at all that I will encounter some kind of memory related error? Like, stacks crushing heaps or dogs and cats sleeping together?

更具体地说,当文件的大小为4GB时,是否可以插入一行代码来停止打印行?为了安全起见?

EDIT even more specifically, is there a line of code I could put in to stop the printing of lines when the file's size is 4GB? Just to be safe?

成功:一整夜不留时间后,我得到的素数不超过13 KB,我得到的最高是22947217,就像成千上万的素数一样.成功!

success: after leaving it on all night I got no more than 13 KB of primes, The highest I got was 22947217, which is like tens of thousands of primes. Success!

推荐答案

使用慢速算法的可能性更大.随着质数变大,您的程序将需要越来越长的时间来计算单个质数.如果让它运行一整夜,则文本文件在早上不会很大.如果超过两兆,我会印象深刻.

More than likely you are using an algorithm that is slow. As the primes get larger your program will be taking longer and longer to calculate a single prime. If you let it run over night the text file is not going to be very large in the morning. I'd be impressed if it's over a couple of megs.

这篇关于.txt文件大小是否有上限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆