|
-
Reading large text files ( about 10 MB )
Friends,
Iam trying to read text files and display them inside a scroll pane. The
following code works absolutely fine for smaller file sizes upto 5-6 MB.
But for larger files, an OutOfMemory error is thrown. Though I can understand
its meaning - i just want to know if there is any better way of handling
large files.
NB: The same file loads perfect even using NotePad !!
Thanks,
Anand
//code
// build the scroll pane and the text area
public void addScrollText() {
// create the editor pane
jePane = new JEditorPane();
jePane.setEditable(false);
// create the scroll pane
jsPane = new JScrollPane(jePane);
jsPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
getContentPane().add(jsPane);
}
public void displayFile(File jfile) {
try {
FileInputStream fis = new FileInputStream(jfile);
jePane.read(fis,jfile);
} catch (IOException e) {
System.out.println("IO Exception in display file");
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks