[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.
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8028387
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 "\\Z"
it reads the entire file, but with "\\z"
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.
Description of \Z and \z can be found at:
http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#lt
What could be causing this strange behavior?
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());
Output: using Z : 9720 Using z : 1024
Thanks!
Details about the file/java-version:
Running Ubuntu with java-6-openjdk-amd64 (tested also with oracle java6) File is simple text file UTF-8 encoded.