Example usage for java.util Scanner delimiter

List of usage examples for java.util Scanner delimiter

Introduction

In this page you can find the example usage for java.util Scanner delimiter.

Prototype

public Pattern delimiter() 

Source Link

Document

Returns the Pattern this Scanner is currently using to match delimiters.

Usage

From source file:MainClass.java

public static void main(String args[]) throws IOException {

    Scanner src = new Scanner("1,2,3,4");

    src.useDelimiter(", *");
    System.out.println(src.delimiter());
}

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();// w w  w.  j a va2s  . com
}

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 www.j av 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 true ";

    Scanner scanner = new Scanner(s);

    System.out.println(scanner.nextLine());

    // change the delimiter of this scanner
    scanner.useDelimiter(Pattern.compile(".ll."));

    // display the new delimiter
    System.out.println(scanner.delimiter());

    scanner.close();//from  w w  w  .  j  ava  2 s  . c  om
}