代号中的文本屏幕一,如何读取文本文件? [英] Textscreen in Codename One, how to read text file?
问题描述
我想向我的Codename One应用添加帮助屏幕。
由于文本的长度与其他字符串一样长,我想将其放在单独的文件中并将其添加到应用程序包中。
I want to add a help screen to my Codename One App. As the text is longer as other strings, I would like put it in a separate file and add it to the app-package.
我该怎么办这个?
(我已经知道如何将字符串放入文本区域中了,如何在一个字符串中轻松读取该文本文件?)
(I already know how to put the string into a text area inside a form)
推荐答案
在Codename One Designer中,转到数据部分并添加文件。
In the Codename One Designer go to the data section and add a file.
您只需在其中添加文本并使用 myResFile.getData( name);
。
You can just add the text there and fetch it using myResFile.getData("name");
.
您也可以将文件存储在src目录中,并使用 Display.getInstance()。getResourceAsStream( / filename.txt);
You can also store the file within the src directory and get it using Display.getInstance().getResourceAsStream("/filename.txt");
这篇关于代号中的文本屏幕一,如何读取文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!