title: Reading String in java
body: <p>I've been working on this code for school to create a course, users, students, and teachers but I ran into a snag while creating a course.</p>
  
  <p>What I want to do is (in the terminal) read an input stream such as "CSC 110 Into to java" and enter all of it into a string. I am using Scanner for input. and have tried hasNext() and nextLine() besides next(). I thought about writing a function to use a char array get the entire string and then convert the char array into a string. </p>
  
  <p>First I wanted to know if there was an easier solution?</p>
  
  <p>Edit: Sorry I wasn't clear. Without going into all of my code.</p>
  
  <p>current Code:</p>
  
  <pre><code>        System.out.print("Enter the Course Title: ");
          title = keyboard.nextLine();
          System.out.print("Enter a Brief Course Description: ");
          desc = keyboard.nextLine();
  
          if (t != null)
          {   
              do
              {
                  System.out.println("\nPick a teacher\n");
  
                  for (int j = 0; j &lt; t.size(); j++)
                  {
                      nTeacher = t.get(j);
                      s += "\t(" + (j+1) + ") " + nTeacher + "\n";
                  }
  
                  System.out.print(s + "\nEnter the Teacher ID: ");
                  int tId = keyboard.nextInt(); // My error
  </code></pre>
  
  <p>Current error:</p>
  
  <pre><code>Enter the Course Title: CSC 110 Into to java
  
  Enter a Breif Course Description: 
  Pick a teacher
  
  Enter the Teacher ID: 
  Exception in thread "main" java.util.InputMismatchException
      at java.util.Scanner.throwFor(Scanner.java:857)
      at java.util.Scanner.next(Scanner.java:1478)
      at java.util.Scanner.nextInt(Scanner.java:2108)
      at java.util.Scanner.nextInt(Scanner.java:2067)
      at Prototype.classCreator(Prototype.java:530)
      at Prototype.mainMenu(Prototype.java:181)
      at Prototype.login(Prototype.java:121)
      at Prototype.main(Prototype.java:48)
  </code></pre>
  
  <p>When I use nextLine()</p>
  
  <pre><code>Create Class
  Enter the courseID: 27222
  Enter the Course Title: Enter a Brief Course Description: 
  </code></pre>
  
  <p>Intended result:</p>
  
  <pre><code>Create Class
  Enter the courseID: 27299
  Enter the Course Title: CSC 110 Into to Java
  Enter a Brief Course Description: Introduction to programming
  Pick a teacher
  (1) ID: 1111    Name: Bob
  Enter the Teacher ID: 1
  Class Created
  </code></pre>
  
  <p>I understand that when I have three strings "CSC 110 Intro" it get to the input for nextInt() but I don't understand why nextLine() is writing my println's like this.</p>