Apologies if this is not worded well..
Basically I have this line in a servlet -
FileInputStream flinp = new FileInputStream("C:\\xampp\\img\\"+empid+".jpg");
where empid is a string.
So currently I am getting files with the empid as the name, but I need to get files that have the empid ANYWHERE in the name.. so for example if my empid is 2500, I need to get the file if its called anything like -
- 2500_Amy
- Amy_2500
- Amy2500
- 2500Amy
etc.. Can anyone help with this? Is it regex I need to use and if so what do I write? Thanks
I tried this but bringing me an error -
FileInputStream flinp = new FileInputStream("C:\\xampp\\img\\"+.*?empid.*+".jpg");
EDIT -
BTW, in my jsp I have a loop with this line in it so that multiple empid's are passed to the "ReadImage" servlet and multiple images are read.. not sure if this makes my question any different but just to add it anyway -
<img src='<%=request.getContextPath()%>/ReadImages?id<%=thisemp.getEmpGid()%>'
FileInputStreamwith a regex. What would it point to, a random file that matches if there's more than one? Also, regex matches are not free. You need to enumerate the files in the directory, and try to match each one with regex - then decide what to do if there are none or more than one.