我在寻找一些关于如何读取具有特定格式的文本文件的帮助,并将它们分配给我的程序中的变量。读取具有特定格式的文本文件
TextFile.txt的
//Variables
start={x}
forward={c}
end={y}
pause={p}
path={x, c, c, c, c, p, c, c, y}
Class.java
public void readFile()
{
char start, forward, end, pause;
BufferedReader reader =
new BufferedReader (
new InputStreamReader (new FileInputStream (TextFile.txt)));
String line;
while ((line = reader.readLine()) != null)
{
if (line.startWith ("//") || line.trim().isEmpty())
continue; // Ignore the line
//**This is the part I need help with**
}
}
可能有人请解释:我可以分配值,从文本文件中的变量?
因此,例如,开始将等于 'X',正向应该是 'C' 等
感谢。
在上面的例子中,'path'是一个数组吗? –
路径将是一个链接列表,每个节点都是一个字符。 – GuestUser140561
这些是文件中唯一的变量吗?关于后退,左侧,右侧等等? –