List of utility methods to do Scanner Usage
List | joinSqlStatements(Collection join Sql Statements List<String> scriptList = new ArrayList<String>(); for (String script : scripts) { script = script.trim(); StringBuilder sb = new StringBuilder(); boolean blankLine = false; Scanner scanner = new Scanner(script); while (scanner.hasNextLine()) { String temp = scanner.nextLine(); ... |
char | leerOpcion(String opciones, String msgUsr, String msgErr) leer Opcion char dato = 0; boolean lecturaOK = false; do { try { System.out.print(msgUsr); dato = SCN.nextLine().charAt(0); if (opciones.contains(dato + "")) { lecturaOK = true; ... |
String | leerTexto(String msgUsr) leer Texto System.out.print(msgUsr);
return SCN.nextLine();
|
String[] | listify(String s, String prefix, String... ignorelist) listify ArrayList<String> l = new ArrayList<String>(); Scanner m = new Scanner(s); while (m.hasNextLine()) { String b = m.nextLine().trim(); if (b.length() <= 0) continue; l.add(prefix + b); if (ignorelist.length > 0) { ArrayList<String> x = new ArrayList<String>(); for (String a : l) { boolean good = true; for (String bad : ignorelist) { if (!a.contains((CharSequence) bad)) continue; good = false; if (!good) continue; x.add(a); l = x; return l.toArray(new String[0]); |
String[] | listify(String s, String prefix, String... ignorelist) Parses a String, assumed to be a list, into a String array. ArrayList<String> l = new ArrayList<String>(); Scanner m = new Scanner(s); while (m.hasNextLine()) { String b = m.nextLine().trim(); if (b.length() > 0) l.add(prefix + b); if (ignorelist.length > 0) { ... |
ArrayList | loadElements(Scanner scan, int elementCount, int skipCount) load Elements ArrayList<Integer> sequence; if (elementCount > 0) { sequence = new ArrayList<>(elementCount); } else { sequence = new ArrayList<>(); while (scan.hasNextInt() && skipCount-- != 0) { scan.nextInt(); ... |
HashMap | loadStringDoubleMap(Scanner scanner) load String Double Map HashMap<String, double[]> ret = new HashMap<String, double[]>(); int dimX = scanner.nextInt(); int dimY = scanner.nextInt(); scanner.nextLine(); for (int i = 0; i < dimX; i++) { String word = scanner.nextLine(); double[] vals = new double[dimY]; for (int j = 0; j < dimY; j++) { ... |
int | menu() menu int selection; Scanner input = new Scanner(System.in); System.out.println("Please enter a number to perfom the desired operation"); System.out.println("-------------------------\n"); System.out.println("1 - Call the international geocoding API provided by PostCodeAnywhere (SOAP)"); System.out.println("2 - Call the global weather API provided by WorldWeatherOnline (REST)"); System.out.println("3 - Quit"); selection = input.nextInt(); ... |
char | nextChar(Scanner s) read exactly one character from the scanner from: http://stackoverflow.com/a/13942707/1066911 return s.findInLine(".").charAt(0); |
int | nextInt(final Scanner sc) next Int try { return sc.nextInt(); } catch (final InputMismatchException ime) { return 0; |