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");
}
}