java - static method returns empty hashmap -


i have code there 2 classes, , and util class static methods b. class b has static method called a. static method returns hashmap (); although map built static method in clas b, map empty when call method of b a. thoughts?

the following static method class b correctly build map.

package fileutils;  import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.util.enumeration; import java.util.hashmap; import java.util.map; import java.util.jar.jarentry; import java.util.jar.jarfile; import com.google.common.io.files;  public class jarfileutils {     //returns sql queries map public static map<string, string> getsqls(string jarfilefullpath){       map<string, string> sqldata = new hashmap<string, string>();     try {          jarfile jarfile = new jarfile(jarfilefullpath);          enumeration enumeration = jarfile.entries();          while (enumeration.hasmoreelements()){              sqldata = getsqldatahelper(enumeration.nextelement(), jarfile);          }          jarfile.close();           } catch (ioexception e) {         e.printstacktrace();     }     return sqldata; }  //helper fetch sql info private static map<string, string> getsqldatahelper(object obj, jarfile jarfile)  { map<string, string> sqls = new hashmap<string, string>();   jarentry entry = (jarentry)obj;    string path = "/"+entry.getname();   if(files.getfileextension(path).equalsignorecase("sql")){     inputstream input;     try {         input = jarfile.getinputstream(entry);         sqls.put(files.getnamewithoutextension(path), readsqlfile(input));        } catch (ioexception e) {         e.printstacktrace();             }   }   system.out.println(sqls.tostring());   return sqls;       }  //reads given sql file private static string readsqlfile(inputstream input) throws ioexception {       inputstreamreader isr = new inputstreamreader(input);       bufferedreader reader = new bufferedreader(isr);       stringbuilder sqlquery = new stringbuilder();       string line;       while ((line = reader.readline()) != null) {           sqlquery.append(line);           sqlquery.append("\n");       }       reader.close();       return sqlquery.tostring();     } } 

the following call above static method class a. size of map 0 reason.

//get list of sqls in jar file     map<string,string> sqlsextracted = jarfileutils.getsqls(currentprojectfullpath);     system.out.println("size = "+currentprojectfullpath+" = "+sqlsextracted.size()); 

please advise,

thanks!

adding comment possible answer, since might point problem.

getsqls() going through each entry in jar file, returns result of last entry. perhaps last entry doesn't contain sql files?


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -