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 fi
What about just creating one file for each prime number and then use the filename to display the number?
Somehow I doubt that when having your program run overnight, that the filesize will be a problem, considering that it will take longer to find primes as numbers get bigger. Just make sure you clean up or you might eat up all your RAM.
To answer your question: Theoretically, the filesystem restricts file size. However, a lot of text editors crash (vim does not) when loading big files (> 100 MB), because they try to fit it in one buffer.
To sum up, consider splitting up your files into chunks the weakest link (text editors) can handle.
Only as to the size of the place you're storing the text file on disk.
And, if you're not writing it all right away, your memory + virtual memory.
How about saving some CPU cycles and just downloading a pre-computed list of primes? Or is it more "the thought that counts"? :)
You might consider tracking the number of bytes you write to each file and switching to a new one after some number of bytes. You might also provide a viewer for your files so your friend can see his gift more easily. :)