简体   繁体   中英

What is the Android/Java version of iOS/Objective-C's NSScanner?

I'm working in a game for Android, but is the same game that exist for IOS, and there have a NSScanner class that is used for get the images in a file .SVG, and I need a class that makes the same thing. I found some classes for android, but these don't use keys like the NSScanner... Can someone help me??

The code in Objective C:

                    if(![scanner scanUpToString:@"circle" intoString:nil]) 
                        break;

        if([scanner isAtEnd]) 
                        break;

        [scanner scanUpToString:@"id" intoString:nil];

        if([scanner scanString:@"id=\"grab" intoString:nil]) {
            isGrab = YES;
        } else if([scanner scanString:@"id=\"star" intoString:nil]) {
            isGrab = NO;
        }

        [scanner scanUpToString:@"cx" intoString:nil];

        [scanner scanString:@"cx=\"" intoString:nil];

        [scanner scanFloat:&x];

        [scanner scanUpToString:@"cy" intoString:nil];

        [scanner scanString:@"cy=\"" intoString:nil];

        [scanner scanFloat:&y];

Heres android's scanner A Scanner can also find or skip specific patterns without regard for the delimiter. All these methods and the various next* and hasNext* methods may block.

The Scanner class is not thread-safe.

Hopefully this isn't the same scanner you were talking about.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM