I’ve got this java function that extracts strings from Inputstreams and returns a List. It uses java.util.Scanner and java.util.regex.Pattern.
Problem is, it only seems to work the first time I call it. If I reverse my calls, again only the first one works, the second call never returns any matches.
List lsphones = extract(is,pattern,0);
List lsemails = extract(is,pattern”,0);
I suspect I need to reset the Lists or something in the funciton -if not the function itself somehow. I’ve tried but keep getting exceptions when I do.
public static List<String> extract(InputStream in,String matchpattern,int grp) {
..
scanner.close();
return what
I’m developing this in the Android SDK.
Does your extract method read until the end of the stream? I suspect you need to close and reopen the stream to start again from the beginning. If this is the case, a better approach would be to do all your matching on one pass through the stream.