1
我有一个包含几段信息(纯文本)的txt文件,我将如何在textarea中显示此文件。到目前为止,我试过在vaadin布局中显示txt文件
FileResource file = new FileResource(new File("/path/to/file");
TextArea text = new TextArea();
text.setData(file);
这不起作用
我有一个包含几段信息(纯文本)的txt文件,我将如何在textarea中显示此文件。到目前为止,我试过在vaadin布局中显示txt文件
FileResource file = new FileResource(new File("/path/to/file");
TextArea text = new TextArea();
text.setData(file);
这不起作用
不要使用setData()
方法,而是在setValue(....)
方法。请参阅Book of Vaadin和API doc中的TextArea
主题。
这需要一个字符串,所以您必须从文件中读取字符串中的文本,然后在TextArea上使用setValue()
。
set/getData()方法允许您保存Vaadin没有使用的“私有”数据。