You'll probably be retrieving the contents of the JTextPane
as a String
at some point which means that you'll have a technical upper limit of just over 2 billion characters (as discussed here). Having said that the application will become totally unresponsive long before you get anywhere close to that number of characters.
As for saving the contents to a file you shouldn't have any problems writing out that much data assuming you have a couple of GB of free disk space. If you need an example of writing a file have a look here.
It is possible that you are losing the end of the data because you aren't closing the stream when you are finished with it or you are using a buffer and failing to flush it correctly after the last write.