Hi everybody.

I am a student in computers at the Hebrew University in Jerusalem.

I started to work with Java - and working with Product Version:

NetBeans IDE 6.5
Java: 1.6.0_11; Java HotSpot(TM) Client VM 11.0-b16
System: Windows XP version 5.1 running on x86; Cp1252; en_US

I have an urgent question:

If I look for a patern in a scanner and I find it - How do I know the position in the scanner? the pattern helps me to be near data I know is afterward but i can not find a pattern or I dont know how it looks. so I look for the pattern (can be date) and I know that my data is afterwards and I want to collect from that position only for a number of bytes or until the end of a sentence..

I can't find any command - the start() and end() from the scanner are private. or can I access them?

Here is a function I wrote in Java:

private static String find(Scanner sc, String pattern) {
    String Stoken;
    while (( Stoken = sc.findInLine(pattern)) == null) {
        if (sc.hasNextLine()) {
            sc.nextLine();           
        } else {
            return null;
        }
    }  
    return Stoken;
}

Thanks

Edited 3 Years Ago by Reverend Jim: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.