title: Can Scanner.next() return null or empty string?
body: <p>I'm learning Java coming from other programming languages (Js, C and others..)</p>
  
  <p>I'm wondering if under any circumstances the <code>Scanner.next()</code> method could return (without throwing) an invalid string or less than one character (ie. <code>null</code> or empty string <code>""</code>). I'm used to double-check user input for any possible unexpected/invalid value, but I wanted to know if testing for <code>null</code> and <code>myString.length() &lt; 1</code> is always unnecessary or could be useful/needed.</p>
  
  <p>I'm asking in particular when reading from the commandline and <code>System.in</code>, not from other Streams of Files. Can I safely get the first character with <code>myString.charAt(0)</code> from the returned value when reading normally from the terminal input (ie. no pipes and no files, straight from terminal and keyboard)?</p>
  
  <p>I searched the Java SE 9 API Docs and couldn't find mentions about possibly unexpected return values. In case anything goes wrong with input it should just throw an Exception, right?</p>
  
  <p>Example (part of main method without imports):</p>
  
  <pre><code>Scanner keyboard = new Scanner(System.in);
  
  System.out.print("Enter a selection (from A to E): ");
  String res = keyboard.next();
  
  if (res == null || res.length() &lt; 1) {
      // Unnecessary if?
  }
  </code></pre>