4

Possible Duplicate:
what is the Java equivalent of sscanf for parsing values from a string using a known pattern?

I'm pretty new to Java, but seeing how useful the sscanf function is, I wonder if there is an equivalent in Java. I've got many pretty much formatted strings (namely, writing scripting language for my purposes), so regular expressions are overkill here.

Community
  • 1
  • 1
Dariusz G. Jagielski
  • 655
  • 3
  • 11
  • 22
  • 3
    Possible duplicate may be http://stackoverflow.com/q/8430022/776084 – RanRag May 10 '12 at 19:51
  • Uh... Sorry about that. I always do search and check links returned when writing post but it didn't show up. Also it seems that answers on that code are either filled with bulky code or regular expressions that are as I explained overkill in my case. – Dariusz G. Jagielski May 10 '12 at 19:55
  • I would vote for reopening if possible. The other question is best answered with a SimpleDateFormat answer. – user unknown May 11 '12 at 15:21

1 Answers1

6
Scanner scanner = new Scanner ("2 A text 3 4");
scanner.nextInt (); // 2
scanner.next ();    // A 
scanner.next ();    // text
scanner.nextInt (); // 3
scanner.nextInt (); // 4
// and so on.

Here is the official documentation of the Scanner class.

user unknown
  • 35,537
  • 11
  • 75
  • 121