List of usage examples for java.util Scanner Scanner
public Scanner(ReadableByteChannel source)
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.next(".")); scanner.close();/* www . ja va 2s. c o m*/ }
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 System.out.println(scanner.hasNextBigInteger()); System.out.println(scanner.next()); }/* w w w . j a v a2s. c o m*/ scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "23 java2s.com 1 + 1 = 2.0 "; Scanner scanner = new Scanner(s); // scan next token as a Big Integer with radix 4 System.out.println(scanner.nextBigInteger(4)); scanner.close();/*ww w . j a v a2 s.c o m*/ }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0"; Scanner scanner = new Scanner(s); // print the next line of the string System.out.println(scanner.nextLine()); // print the delimiter this scanner is using System.out.println(scanner.delimiter()); scanner.close();/*from w ww. ja v a 2 s . c o m*/ }
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 w w w . j av 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"; Scanner scanner = new Scanner(s); // find a string "com" System.out.println(scanner.findInLine("com")); // print the rest of the string System.out.println(scanner.nextLine()); scanner.close();/*from w w w .ja v a2 s. co m*/ }
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()); }/*w w 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"; 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()); }//from w w w. jav a2s .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); while (scanner.hasNext()) { // check if the scanner's next token is a byte System.out.println(scanner.hasNextByte()); System.out.println(scanner.next()); }//from w ww .jav a2 s .co m scanner.close(); }
From source file:MainClass.java
public static void main(String args[]) { String instr = "10 99.88 scanning is easy."; Scanner conin = new Scanner(instr); while (conin.hasNext()) { if (conin.hasNextDouble()) { System.out.println(conin.nextDouble()); }/* www . j ava 2 s . c om*/ } }