Alguém pode me ajudar a passar campos de um registro lido de um arquivo para uma arvore de busca…
Tô tentando passar strings mas não sei como faço.
public static void main(String[] args) throws FileNotFoundException, IOException {
RandomAccessFile fd;
String line,lins[],f1,f2,f3,f4;
int i,recs;
int ids1[];
String ids2[],ids3[];
Double ids4[];
int index;
String data;
TreeSearch s = new TreeSearch();
TreeAVL a = new TreeAVL();
fd = new RandomAccessFile("C:\Documents and Settings\Raquel\Meus documentos\Dados\Java\Projects\Tree\prods.txt","r");
recs = 0;
while ((line = fd.readLine()) != null)
recs++;
fd.seek(0);
ids1 = new int[recs];
ids2 = new String[recs];
ids3 = new String[recs];
ids4 = new Double[recs];
i = 0;
while ((line = fd.readLine()) != null){
lins = line.split("\t");
f1 = lins[0];
f2 = lins[1];
f3 = lins[2];
f4 = lins[3];
ids1[i] = Integer.parseInt(f1);
ids2[i] = f2;
ids3[i] = f3;
ids4[i] = Double.parseDouble(f4);
a.add(ids1[i]);
s.add(ids1[i]);
a.add(ids4[i]); // isso aq da erro...
}
Random rnd = new Random();
index = rnd.nextInt(ids1.length - 1); // sorteia um valor qualquer da arvore
data = String.valueOf(index);
a.show();
s.show();
System.out.println("h = " + a.height());
}
}
eu realmente não sei como fazer… alguém pode me dar uma luz pra resolver esse trabalho?