Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.AsylumDevs.AsylumMines.Utils;
- import java.util.Arrays;
- import java.util.function.Predicate;
- class TimeScanner {
- private char[] time;
- private int index = 0;
- public TimeScanner(String time) {
- this.time = time.toCharArray();
- }
- public boolean hasNext() {
- return this.index < this.time.length - 1;
- }
- public long nextLong() {
- return Long.parseLong(String.valueOf(this.next(Character::isDigit)));
- }
- public String nextString() {
- return String.valueOf(this.next(Character::isAlphabetic));
- }
- private char[] next(Predicate<Character> whichSatisfies) {
- int startIndex = this.index;
- while (++this.index < this.time.length && whichSatisfies.test(Character.valueOf(this.time[this.index]))) {
- }
- return Arrays.copyOfRange(this.time, startIndex, this.index);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement