title: java string variable using .next() or .nextLine()
body: <p>the following is my sources code:</p>
  
  <pre><code>package functiontest;
  
  import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.util.Scanner;
  
  public class FunctionTest {
  
  public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
      int option;
      String cname, cpassword="testpassword",chp="010-000000";
  
  //        cname="clerk test";
  
      System.out.println("1. add");
      System.out.println("2. delete");
      option = scan.nextInt();
      switch(option)
      {
          case 1:
              System.out.print("Enter clerk name:\t");
              cname = scan.nextLine();
              File cfile = new File("clerk/"+cname+".txt");
                 FileWriter cwrite;
                 try
                 {
                     cwrite = new FileWriter(cfile);
                     BufferedWriter cbuf = new BufferedWriter(cwrite);
                     cbuf.write("clerk name:\t" +cname);
                     cbuf.write("clerk password:\t"+cpassword);
                     cbuf.write("clerk handphone number:\t"+chp);
                     cbuf.flush();
                     cbuf.close();
                     System.out.println("The clerk profile create completely");
                 }catch(IOException e)
                 {
                     System.out.println("Error! clerk profile cannot create");
                 }
              ;break;
          case 2:
              String dclerk;
  //                dclerk = "clerk test";
                  System.out.print("\nPlease enter clerk name for delete:\t");
                  dclerk = scan.next();
                  File dcfile = new File("clerk/"+dclerk+".txt");
                  if(!dcfile.exists()) 
                  {
                      System.out.println("Error! the clerk profile not exist");
                  }
                  try
                  {
                      dcfile.delete();
                      System.out.println(dclerk + "'s prifle successful delete");
                  }catch(Exception e)
                  {
                      System.out.println("Something wrong! " + dclerk +" profile cannot delete");
                      };break;
          }
      }
  }
  </code></pre>
  
  <p>i cannot the enter the variable name cname</p>
  
  <pre><code>        cname = scan.nextLine()
  </code></pre>
  
  <p>when i run the program it show the result as below:</p>
  
  <pre><code>run:
  1. add
  2. delete
  1
  Enter clerk name:   The clerk profile create completely
  </code></pre>
  
  <p>when i use <code>.next():</code></p>
  
  <pre><code>cname = scan.next()
  </code></pre>
  
  <p>it cannot read the </p>
  
  <pre><code>cname
  </code></pre>
  
  <p>with spaces, example </p>
  
  <pre><code>clerk test 
  </code></pre>
  
  <p>it will read</p>
  
  <pre><code>clerk 
  </code></pre>
  
  <p>only how should i do?</p>