List of usage examples for java.util Scanner close
public void close()
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0"; Scanner scanner = new Scanner(s); while (scanner.hasNext()) { // check if the scanner's next token is a BigDecimal System.out.println(scanner.hasNextBigDecimal()); System.out.println(scanner.next()); }// w w w.j ava 2s . c om scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0 true "; Scanner scanner = new Scanner(s); System.out.println(scanner.nextLine()); // change the locale of the scanner scanner.useLocale(Locale.ENGLISH); // display the new locale System.out.println(scanner.locale()); scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0"; Scanner scanner = new Scanner(s); while (scanner.hasNext()) { // check if the scanner's next token is a byte with radix 4 System.out.println(scanner.hasNextByte(4)); System.out.println(scanner.next()); }//ww w . j a v a 2 s. co m scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0 true "; Scanner scanner = new Scanner(new StringReader(s)); System.out.println(scanner.nextLine()); // change the radix of the scanner scanner.useRadix(32);//ww w.ja v a 2s . c o m // display the new radix System.out.println(scanner.radix()); scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0 true "; Scanner scanner = new Scanner(s); System.out.println(scanner.nextLine()); // change the delimiter of this scanner scanner.useDelimiter("Wor"); // display the new delimiter System.out.println(scanner.delimiter()); scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0 "; Scanner scanner = new Scanner(s); while (scanner.hasNext()) { // check if the scanner's next token is an int with a radix of 4 System.out.println(scanner.hasNextInt(4)); System.out.println(scanner.next()); }/*from w w w. j a va2s. c o m*/ scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0 "; Scanner scanner = new Scanner(s); // check if next token matches the pattern and print it System.out.println(scanner.next("java2s")); // check if next token matches the pattern and print it System.out.println(scanner.next("=")); scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0"; Scanner scanner = new Scanner(s); System.out.println(scanner.hasNext(Pattern.compile(".com"))); System.out.println(scanner.hasNext(Pattern.compile("1"))); // print the rest of the string System.out.println(scanner.nextLine()); scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0"; Scanner scanner = new Scanner(s); while (scanner.hasNext()) { // check if the scanner's next token is a BigInteger with radix 5 System.out.println(scanner.hasNextBigInteger(4)); System.out.println(scanner.next()); }//from ww w .j a v a 2 s. c om scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0 true "; Scanner scanner = new Scanner(s); while (scanner.hasNext()) { if (scanner.hasNextShort()) { System.out.println("Found :" + scanner.nextShort()); }// w ww . j a va 2 s .c o m System.out.println("Not Found :" + scanner.next()); } scanner.close(); }