Question

I would like to know the maximum size of data that a JTextPane could hold. This is needed as I am unable to retrieve the entire contents of a JTextPane , for writing out to a file , in an application at my office.

In that application I generate XML based on some business logic , load it into a JTextPane and upon validation of the same , write it out to the disk.

I'm losing a part of the JTextPane contents ( the data that is to be written out) on creating a File object for this purpose.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top