• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help me out

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
reply
    Bookmark Topic Watch Topic
  • New Topic