title: Behavior of using \Z vs \z as Scanner delimiter
body: <p>[Edit] I found the answer, but I can't answer the question due to restrictions on new users. Either way, this is a known bug in Java.</p>
  
  <p><a href="http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8028387" rel="noreferrer">http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8028387</a></p>
  
  <p>I'm trying to read a file into a string in Java 6 on 64 bit ubuntu. Java is giving me the very strange result that with <code>"\\Z"</code> it reads the entire file, but with <code>"\\z"</code> it reads the entire string up to 1024 characters. I've read the Java 6 API for all the classes and I am at a loss.</p>
  
  <p>Description of \Z and \z can be found at:</p>
  
  <p><a href="http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#lt" rel="noreferrer">http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#lt</a></p>
  
  <p>What could be causing this strange behavior? </p>
  
  <pre><code>String fileString = new Scanner(new File(fileName)).useDelimiter("\\z").next();
  String fileString2 = new Scanner(new File(fileName)).useDelimiter("\\Z").next();
  System.out.println("using Z : " + fileString2.length());
  System.out.println("Using z "+ fileString.length());
  </code></pre>
  
  <p>Output:
  using Z : 9720
  Using z : 1024</p>
  
  <p>Thanks!</p>
  
  <p>Details about the file/java-version:</p>
  
  <p>Running Ubuntu with java-6-openjdk-amd64 (tested also with oracle java6)
  File is simple text file UTF-8 encoded.</p>