I can not get my head around this.
System.err.println(convertPdfToText(save).split("3\\.8").length);
as expected prints out a result of 3.
In fact, I want a user to be able to obtain the same. Therefore, when I run this code:
System.err.println(convertPdfToText(save).split(seperator).length);
When the user has entered “3\\.8” in a JInputField, I get the length of the array being returned as 1.
What exactly is happening here?
"\\"in a Java program represents a string containing one\. In your case, the user would have to enter3\.8to get the string represented by the Java code"3\\.8".That is, you seem to be confused by the difference between Java’s syntax for string literals (which treats
\and"specially) and strings entered from external sources (where every character stands for itself).