I need to check if a file is an SQL file based off strings for example:
com/cerner/careconcepts/allergy/data/action/sql/ActivityDataReltnQuery.sql
So i guess a regex as follows should be enough? This works in http://regexpal.com/ but not in my code:
fileName.matches(".sql$")
Here is the code where i am trying to find all ".sql" files within a JarFile:
package jarreader;
import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public class processJar {
public static void main(String[] args){
//File file = new File(".");
//for(String fileNames : file.list()) System.out.println(fileNames);
try {
JarFile jarFile = new JarFile("allergies-2.1.2.jar");
Enumeration enumeration = jarFile.entries();
while (enumeration.hasMoreElements())
getSqlContent(enumeration.nextElement());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static void getSqlContent(Object obj)
{
JarEntry entry = (JarEntry)obj;
String name = entry.getName();
if(name.matches(".sql$")){
System.out.println(name);
}
}
}
I don't get any output name based on the above regex.