编写了一个XEditorPane 类继承自JEditorPane
public class XEditorPane extends
JEditorPane implements KeyListener {
...
/*清空内容,显示文件*/
public void onViewFile(String sFilePath, String sFileName) {
clear();
FileReader a = null;
try {
a = new FileReader(sFilePath);
read(a, null);
} catch (FileNotFoundException e) {
} catch (IOException e) {
} finally {
try {
if (a != null) {
a.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
a = null;
}
installUndoRedo();
setCursor(old);
}
public void clear() {
Document doc = getDocument();
setVisible(false);
try {
doc.remove(0, doc.getLength());
} catch (BadLocationException ex1) {
}
setVisible(true);
repaint();
}
在文件比较大的时候,比如1MB时,读入文件到显示的时候占用时间非常长,cpu也很高,请问各位大侠有没有什么好方法?
------解决方案--------------------
推荐:
http://www.elearning.gov.cn/elearning/user/findclass.do?method=courselist&categoryid=57982540b6cd11d993d0f770c0a83c70&id=2
------解决方案--------------------