You should consider "paging" through the file -- displaying single chunks of the content at a time. Similar to what you would do with paging through records in a database table.
Basically, you keep track of a [page #] and a [page size] (number of chars or bytes in a page). Then use a RandomAccessFile to read [page size] bytes from the file beginning at the appropriate offset ([page #] * [page size]).
You can calculate the number of pages by [file size] / [page size]
Jason
On Tue, Apr 17, 2012 at 8:50 AM, Jeff
<[hidden email]> wrote:
I have the below controller code to allow the user to view the contents of a
files in their browser. This works great for most files but for very large
files (~1GB) this brings the browser to a halt. I'm wondering what the best
way to handle this is.
def displayFileContents = {
render "<textarea rows='30' cols='80'>${new
File(params.path).text}</textarea>"
}
--
View this message in context: http://grails.1312388.n4.nabble.com/Display-contents-of-large-files-in-browser-tp4564788p4564788.html
Sent from the Grails - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email