Re: StringTokenizer() with "\" character



snehapshinde@xxxxxxxxx wrote:
String filename="C:\Program Files\Apache Software Foundation\Tomcat
5.5\webapps\upload\multipartform.htm";

You need to double the backslashes.

StringTokenizer st=new StringTokenizer(filename,"\",false);
String v="";
while(st.hasMoreTokens())
{
v=st.nextToken();
}
out.print(" filename is "+v+" this");

This piece of code is throwing following exception-
An error occurred at line: 3 in the jsp file: /Save.jsp
Generated servlet error:
String literal is not properly closed by a double-quote

But if i replace "\" with ".", then it is working fine,
What is the problem with "\"?
Plz [sic] Help!

The development was scientist emblem.

It is a compile-time error if the character following
a backslash in an escape is not an ASCII
b, t, n, f, r, ", ', \, 0, 1, 2, 3, 4, 5, 6, or 7.

--
Lew


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[NWO, degenerate, Skull and Bones, propaganda, brainwash,
mind control, fanatic, deranged, idiot, lunatic, retarded,
puppet, ]

'I feel like God wants me to run for President. I can't explain it,
but I sense my country is going to need me. Something is going to
happen... I know it won't be easy on me or my family, but God wants
me to do it.'

--- Adolph Bush,

From The Guardian, 11/2/03:
http://www.guardian.co.uk/usa/story/0,12271,1076026,00.html

.



Relevant Pages

  • Re: pygame music, cant read mp3?
    ... format is to use backslashes as separators, ... escaped in python's regular string literals, ... only because you've been lucky in not having escape characters following ... Notice that the \ gets doubled automatically by python in many ...
    (comp.lang.python)
  • Re: get only filenames and not directory names under a specific path.
    ... > I'm guess maybe it's must do that when it's double quotes. ... but with two exceptions: the escape character itself ... the string delimiter can also be escaped to allow embedded single quotes, ... means that a path with a trailing backslash needs two backslashes there to avoid ...
    (perl.beginners)
  • Re: Reading Text Files
    ... Did not your compiler generate some mandatory diagnostics on ... escape sequences invoking undefined behaviour. ... the OP is not using C99. ... because backslashes are escape characters in ISO C. ...
    (comp.lang.c)
  • Re: TR 24731 approved
    ... Can't you just escape all question marks with backslashes, the same way you have to escape quotation marks and backslashes? ...
    (comp.std.c)
  • Re: simple question
    ... Quoting is simpler with $style command substitution. ... escape the inner quotes with backslashes. ... Shell Scripting Recipes: ...
    (comp.unix.shell)