|
Re: Has StyledText a maximum input for data? [message #511704 is a reply to message #511599] |
Tue, 02 February 2010 15:29 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi,
StyledText does not specify a content size limit, but 60MB is larger than is
typically envisioned for uses of StyledText, so it's possible that you're
seeing a bug (eg.- perhaps some int field within StyledText is hitting its
limit, etc.).
That being said, feeding a StyledText 60MB of content up-front is not a good
approach to use. This content should be provided on an as-needed basis
since the user will likely view < 1% of it. This is described in
http://www.eclipse.org/articles/StyledText%202/article2.html .
It would also be interesting to get an idea of how much text can be set
up-front (you said that 10MB of text worked, does 20MB? etc.)
Grant
"Bjoern Berg" <rollin.hand@gmx.de> wrote in message
news:hk8p0p$l0n$1@build.eclipse.org...
> I am trying to read in files with a size about 10 to 60 MB and display
their content in a StyledText widget.
>
> First it was also a problem to display the 10 MB files in the StyledText,
but after changing the NIO-Routine to a loop reading smaller pieces it was
no problem to read in the whole file.
>
> But with files about 60 MB I still have the problem. So my question is, is
there a capacity limit for StyledText or do I something wrong in the read-in
routine?
>
> The code for the read-in-routine looks like this:
>
>
> [...]
> StyledText transcript = new StyledText(top, SWT.BORDER | SWT.MULTI |
SWT.H_SCROLL | SWT.V_SCROLL);
> [...]
> if (file != null && file.exists()) {
> FileInputStream istream = new FileInputStream(file);
> if (istream == null) return;
>
> FileChannel fc = istream.getChannel();
> // Get the file's size and then map it into memory
> int sz = (int)fc.size();
> int cs = 0;
> final int piece = 5120 * 1024; // read almost about 5 MB into cache
> while (cs < sz) {
> MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, cs,
> (sz - cs) < piece ? (sz - cs) : piece);
>
> // Decode the file into a char buffer
> CharBuffer cb = decoder.decode(bb);
> transcript.append(new String(cb.array()));
> transcript.redraw();
> cs += piece;
> }
> fc.close();
> istream.close();
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02747 seconds