hi there,
i m trying to read data from template files..i had already written codes for that thing but finding problem with recrusion...here i m typing my codes...
import java.io.*;
import java.util.Properties;
import java.util.Enumeration;
import java.util.*;
public class CTemplateLoader
{//static Hashtable ht;
static Properties props;
CTemplateLoader(){}
CTemplateLoader(
String templateName){
//System.out.println("name of template :"+templateName);
props= new Properties();
try{props.load (new FileInputStream (
templateName+".template"));}
catch(Exception e){}
}
Hashtable getHashtable(){
return props;
}
public static void subhash(String st)
{System.out.println("in subhash :"+st);
int i=st.indexOf(',');
char charr[]=st.toCharArray();
int startind=0;
int ind=0;
System.out.println("length of string is :"+charr.length);
for (int c=0;c<charr.length;c++ )
{
if(charr[c]==',')
{//ind=c;
System.out.println("Sting is :"+st.valueOf(charr,startind,c-startind));
CTemplateLoader ctl1=new CTemplateLoader(st.valueOf(charr,startind,c-startind));
Hashtable htb=ctl1.getHashtable();
Enumeration e=htb.keys();
while (e.hasMoreElements())
{
//String s=""+htb.get(e.nextElement());
// int i=s.indexOf(',');
// System.out.println(e.nextElement());
if (htb.containsKey("InheriteTemplate"))
{
subhash(""+htb.get("InheriteTemplate"));
}
else
break;
}
startind=c+1;}
if(c==charr.length-1)
System.out.println("Last element is :"+st.substring(startind));
}
}
/*Hashtable getHashtable(String templateName)
{
}*/
public static void main(String[] args)throws IOException
{
CTemplateLoader ctl=new CTemplateLoader("chart");
Hashtable hashTable=ctl.getHashtable();
Enumeration e=hashTable.keys();
//props.propertyNames();
while (e.hasMoreElements())
{
String s=""+hashTable.get(e.nextElement());
int i=s.indexOf(',');
// System.out.println(e.nextElement());
if (hashTable.containsKey("InheriteTemplate"))
{
subhash(""+hashTable.get("InheriteTemplate"));
}
//
}
}
}
--------
now what i want is whenever i got "inheritetemplte"as key i want to execute same method and wanna to store key adn value in hashtable..can anybody help me...