title: How to take input as String with spaces in java using scanner
body: <p>I need to read spaces (present before string and after String)  given as input using Scanner 
  Note : if there is no spaces given in input it should not add space in output</p>
  
  <p>Please find the below code: </p>
  
  <pre><code>package practise;
  
  import java.util.Scanner;
  
  public class scanccls {
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
          Scanner scan = new Scanner(System.in);
           String name= scan.nextLine();
          name+=scan.nextLine();
           scan.close();
  
          System.out.println("Enter your name"+name); 
  
      }
  
  }
  </code></pre>
  
  <p>I am expecting output like: </p>
  
  <ol>
  <li><p>Input :Enter Your name:Chandu Aakash<br>
  Output:chandu Aakash</p></li>
  <li><p>Input: Enter Your name:    (Space..)Chandu Aakash(Space..)<br>
   Output:    (space.. )chandu Aakash(Space..)</p></li>
  </ol>