List of utility methods to do Scanner Usage
Scanner | createKeyboardScanner() Creates and returns a Scanner that can be used to read from the keyboard. return new Scanner(System.in); |
Scanner | createScannerForString(String s) Creates a Scanner that can be used to read directly from a given text string. return new Scanner(s); |
void | enterToContinue() enter To Continue Scanner scanner = new Scanner(System.in); System.out.println("Press enter to continue."); scanner.nextLine(); |
boolean | equalsToIgnoreEndline(String expected, String actual) compares two strings for equality, line by line, ignoring any difference of end line delimiters contained within the 2 Strings. if (expected == null && actual == null) { return true; if (expected != null ^ actual != null) { return false; Scanner scanner1 = new Scanner(expected); Scanner scanner2 = new Scanner(actual); ... |
String | fromStringToQuery(String value) from String To Query String query = ""; boolean isOpenedQuote = false; Scanner sc = new Scanner(value); while (sc.hasNext()) { String next = sc.next(); if (next.contains("\"") || isOpenedQuote) { query += next; if (next.contains("\"")) { ... |
boolean | getBoolean() get Boolean char c = commandLine.nextLine().toLowerCase().trim().charAt(0); return 't' == c; |
char | getChar() get Char char choice; String line = commandLine.nextLine().toLowerCase().trim(); if (line.length() == 0) { choice = ' '; } else choice = line.charAt(0); return choice; |
List
| getConstantPoolsFromText(String text) get Constant Pools From Text Scanner scanner = new Scanner(text); scanner.nextLine(); List<List<String>> result = new ArrayList<>(); List<String> cPool = new ArrayList<>(); result.add(cPool); while (scanner.hasNextLine()) { String line = scanner.nextLine(); if (line.startsWith("---")) { ... |
String | getDirectoryString() get Directory String String sep = System.getProperty("path.separator"); String dir = commandLine.nextLine().toLowerCase().trim(); if (dir.charAt(dir.length() - 1) != sep.charAt(0)) { dir += sep; return dir; |
int | getEndLine(String cqlString) get End Line System.out.println("Get end line"); Scanner scanner = new Scanner(cqlString); int endLine = -1; while (scanner.hasNextLine()) { endLine++; scanner.nextLine(); return endLine; ... |