我有一个.txt文件:
80,90,100,110,120,130,140,150,160
100,20,22,24,26,28,26,28,29,27
110,30,32,34,36,37,39,37,39,40
120,40,41,42,44,45,46,48,47,49
Run Code Online (Sandbox Code Playgroud)
表示百叶窗价格的表格,第一行是百叶窗的宽度,第一列没有80是高度.剩下的数字是价格.
我已经使用c#做了这个,但在java中我不知道该怎么做,在c#我的代码看起来像这样,一切都很好.有人能在java中向我展示同样的东西吗?theWidth和theHeight是我必须输入尺寸的文本字段.
string[] lines = File.ReadAllLines(@"tabel.txt");
string[] aux = lines[0].Split(',');
for (int i = 0; i < aux.Length-1; i++)
{
if (aux[i] == theWidth.ToString())
{
Console.WriteLine(aux[i]);
indiceLatime = i;
}
}
for (int i = 1; i < lines.Length; i++)
{
aux = lines[i].Split(',');
if (aux[0] == theHeight.ToString())
{
showPrice.Text = aux[indiceLatime + 1];
}
}
Run Code Online (Sandbox Code Playgroud)
在java中我尝试过这样的事情:
try {
BufferedReader inputStream = new BufferedReader(new FileReader("tabel.txt"));
int theWidth = 90;
int theHeight = 100;
int indiceLatime …Run Code Online (Sandbox Code Playgroud)