看一下文件的操作,把文本内容读出来到str
text_id.setText(str);
text_id.setText(str);
解决方案 »
- 解释一下Java中的继承,都继承到什么了
- 奇怪的编码!!jsp页面用gbk编码, 被编译后报错? 奇怪!!!!!!!!!! 奇怪!!!!!!!!!!!!!!
- JAVA代码导出问题
- 关于jar和配置文件的路径的问题,请高手解答,200分献上。
- bufferedreader.read()干吗用的
- 请教接口的问题!
- 怎么为jTabbedPane添加一个选项卡?
- 如何在jbuilder中使用mysql的jdbc驱动呢
- 寻找JBuilder 5 Enterprise的Serial Number和License Key
- 这个问题是不是jdbc-odbc驱动程序的问题?高手请过来看一看.
- 读写文件操作的问题,希望各位能帮我看一下
- 第一次启动BES5.1时的password 和realm是什么?
注:
public void append(String str)
Appends the given text to the text area's current text.
这个问题比较简单,我可以给一部分源码与你! 如下:
StringBuffer results = new StringBuffer("");
LineNumberReader inputFile = new LineNumberReader(new FileReader(in_file));
//Read the contents
while((line = inputFile.readLine()) != null) {
results.append(line + "\r\n"); }
myTextArea.setText(results.toString());******************************************************************
上面的in_file变量是一个File类型的,就是你要显示的文件!(注:这部分代码能打开到4MB的文件大小,大于4MB就要很慢了,而且要报错,这个问题,我还要问问大家为什么?)
String s=reader.readLine();
while (s!=null)
{
textLeft.append(s+"\n");
s=reader.readLine();
}