I am testing something and calling the StringTokenizer
and is getting some weird conversion... forget about the fact that I should be delimiting the \
in the "\7767546"
but I'm just curious what's with the \11
until \77
in java
here is my code:
String path = "C:\\temp\\\\7800000\7767546.pdf";
String delimeter = "\\";
String[] values = new String[3];
int counter = 0;
StringTokenizer st = new StringTokenizer(path,delimeter);
while(st.hasMoreTokens()){
values[counter] = st.nextToken();
System.out.println(" values[counter]" + values[counter]);
++counter;
}
here's the output:
values[counter]C:
values[counter]temp
values[counter]7800000?67546.pdf
if you notice, the \77
in my original String became ?
.....is that like a unicode thing?
As the Java Language Specification states
OctalEscape:
\ OctalDigit
\ OctalDigit OctalDigit
\ ZeroToThree OctalDigit OctalDigit
OctalDigit: one of
0 1 2 3 4 5 6 7
ZeroToThree: one of
0 1 2 3
the following String
or character literal is an octal escape
\77
In octal, the value 77
is 63
which is the ?
character.
Note that this has nothing to do with the StringTokenizer
. It applies to your String
literal
"C:\\temp\\\\7800000\7767546.pdf"
which, if you printed out, would print as
C:\temp\\7800000?67546.pdf
because that is the value stored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With