Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Darla Morrison   on Jun 13 In Java Category.

  
Question Answered By: Alan Palmer   on Jun 13

Notice to this code and I hope solve your problem  :


String finalFileData = null;
File file  = new File (filePath); // filePath is a path + name
try {
FileReader freader = null;
try {
freader = new FileReader(file); // create FileReader
StringBuffer fileData = new StringBuffer((int) file.length());
char[] chars = new char[SOME_BUFFER_SIZE];
int c = freader.read(chars); // read initial buffer into 'chars'
while (c > 0) {
fileData.append(chars, 0, c); // append string from 'chars' to
'fileData'
c = freader.read(chars); // read next buffer into 'chars'
}
finalFileData = fileData.toString();
} finally {
if (freader != null)
freader.close();
}
} catch (Exception e) {
finalFileData = null;
}

Share: 

 
 
Didn't find what you were looking for? Find more on problem in using of textArea Or get search suggestion and latest updates.


Tagged: