
hi i want read special line of file. what am i doing ? I write a code but is false in this programm i want make tree with java but i should read data from file. please help me!
void maketree(BtNode root,int i) throws FileNotFoundException, IOException{
FileInputStream fis=new FileInputStream("D:/myfile.txt");
DataInputStream dis=new DataInputStream(fis);
BufferedReader br= new BufferedReader(new InputStreamReader(dis));
String str[] = new String[130];
BsTree bs = new BsTree();
int index1=0;
int p=0;
String word1=null;
String mean1=null;
String n=null;
BtNode t=root;
if(i%2==0){
index1=str[i].indexOf("=");
System.out.println("index1:"+index1);
word1=str[i].substring(0, index1);
System.out.println("word1:"+word1);
mean1 =str[i].substring(index1+1,str[i].length());
System.out.println("mean1:"+mean1);
BtNode newnode=bs.creatnode(word1, mean1, null,null);
int s=word1.length();
System.out.println("s:"+s);
int s2=root.element1.length();
System.out.println("root.element1"+ root.element1);
System.out.println("s2:"+s2);
if(s<s2)
p=s;
else
p=s2;
System.out.println("p:"+p);
int sum=0,sum2=0;
for(int j=0;j<p;j++){
int c1=word1.codePointAt(j);
sum+=c1;
int c2=root.element1.codePointAt(j);
sum2+=c2;
}
if(sum<sum2){
root.setleft(newnode);
System.out.println("root.left.element1:"+root.left.element1);
//word1=root.left.element1;
//mean1=root.left.element2;
}else{
root.setright(newnode);
System.out.println("root.right.element1:"+root.right.element1);
//BtNode rigt=bs.creatnode(word1, mean1, null,null);
// BtNode rigt=root.right;
// word1=root.right.element1;
//mean1=root.right.element2;
}
maketree(newnode,i++);
//n= word1;
//n=st;
}
}
protected BtNode creatnode(String element1,String element2,BtNode left,BtNode right){
return new BtNode(element1, element2, left,right);
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.