I have problem about applied SwingWorker with FileReader and my point is I need to implement FileReader with SwingWorker to make my UI Show the text from the file and this is my
Works just fine for me:
public class Reader extends SwingWorker<List<String>, String> {
protected List<String> doInBackground() throws Exception {
ArrayList<String> lstText = new ArrayList<String>(25);
BufferedReader in = null;
try {
FileReader read = new FileReader("Scanner.txt");
in = new BufferedReader(read);
String s = null;
while ((s = in.readLine()) != null) {
lstText.add(s);
publish(s);
}
} finally {
try {
in.close();
} catch (Exception e) {
}
}
return lstText;
}
@Override
protected void process(List<String> chunks) {
for (String text : chunks) {
fldText.append(text + "\n");
}
}
@Override
protected void done() {
}
}