# Steps for attaching scanner

* What is Scanner?
  * A class that represents text-based parser.
  * It can parse text data from any source console input,text file, socket, string.

```java
  import java.util.*;
  //OR 
  import java.util.Scanner;
```

* Create instance of Scanner class
  * constructor: `Scanner(InputStream in)`
  * stdin: `System.in`

```java
  Scanner sc=new Scanner(System.in);
```

* To check data type of input type currenly present in the input strream use

```java
    boolean hasNextInt();
    boolean hasNextByte();
    boolean hasNextLong();
    //and so on... 
```

* To read data

```java
  int nextInt() throws InputMismatchException
  double nextDouble() throws InputMismatchException
  String next();
  String nextLine();
  boolean nextBoolean();
  //and so on...
```
