I have a big file which is having 50 mb data.I want to read and append into jTextArea(). But i am getting out of *memory error* while appending data.How can i do this?please anyone help me
example:
BufferedReader br;
StringBuilder builder = new StringBuilder();
try {
br = new BufferedReader(new FileReader("D:\\myFile.txt"));
String line;
try {
while ((line = br.readLine()) != null) {
// process the line.
builder.append(line);// here getting error
}
System.out.println(builder.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
br.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JTextArea jt = new JtextArea();
jt.append(builder.toString();
Try to set up the max size of your JVM