Sscanf equivalent in Java

Possible duplicate:
What is the sscanf Java equivalent for parsing values ​​from a string using a well-known pattern?

I am new to Java, but seeing how useful the sscanf function is, I wonder if there is an equivalent in Java. I have many fairly formatted strings (namely, to write a scripting language for my purposes), so regular expressions are redundant here.

+4
source share
1 answer
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 for the Scanner class.

+6
source

Source: https://habr.com/ru/post/1411855/


All Articles