You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-dev@jakarta.apache.org by Hardeep Singh <ha...@in.velocient.com> on 2002/01/21 07:15:04 UTC
Qusetion
Hi,
I have had this problem for a long time now:
I have written a programme that searches for email IDs in any file. The
relevant piece of code goes like this:
String strRe=new String("[a-z0-9\\.\\-\\_]+@(([a-z0-9\\-\\_])+\\.)+(" +
"com|net|org|edu|int|mil|gov|arpa|biz|" +
"aero|name|coop|info|pro|museum|tv|[a-z]{2})");
try {
pattern = compiler.compile(strRe,AwkCompiler.CASE_INSENSITIVE_MASK);
} catch(MalformedPatternException e) {
System.out.println("Internal error.\n"+e);
return;
}
---
String content=null;
Reader rin=null;
try {
rin=new FileReader(fileName);
}
catch (Exception e) {
// do nothing.
return;
}
AwkStreamInput input=new AwkStreamInput(rin);
boolean hasPrinted=false;
try {
while (matcher.contains(input, pattern)) {
MatchResult result = matcher.getMatch();
if (comma)
if (!hasPrinted)
System.out.print(result);
else
System.out.print(", "+result);
else
System.out.println(result);
hasPrinted=true;
}
}
catch (IOException ioe) {
// just ignore.
}
However, when I try to use this to search into a binary file (esp. a JAR
file), it gives me
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at org.apache.oro.text.awk.AwkMatcher._search(AwkMatcher.java:717)
at org.apache.oro.text.awk.AwkMatcher.contains(AwkMatcher.java:622)
at com.seeingwithc.email.Emails.handleFile(Emails.java:76)
at com.seeingwithc.email.Emails.main(Emails.java:51)
Please help me with this...
Hardeep Singh
http://SeeingWithC.cjb.net
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>