This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes illegal character: \92 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "illegal character: \92" Watch "illegal character: \92" New topic
Author

illegal character: \92

Michael Brewer
Ranch Hand

Joined: Jun 27, 2002
Posts: 54
I'm trying compile a class that I wrote. I get the following compile time exception:

I tried removing the semi-colon to see what other error it would give me, and it gives me the same error pointing now to the location that would have the semi-colon had it not been removed. I assumed this meant I somehow had a hidden character in there.
I deleted a lot of the text around that spot and retyped it, but I still get the same error.
I assume this is something very basic, and hopefully some of the long-timers have run into it before. Help please!
[ November 08, 2002: Message edited by: Michael Brewer ]
[ November 08, 2002: Message edited by: Michael Brewer ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Right at the beginning of your string there is a closing quote: "<div class="
So the rest is crap to the compiler.
Frankly, don't write strings like that! Split them up nicely and concatenate them with the "+" operator.
-Barry


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Or better yet, use StringBuffer to build up complex strings; much more efficient than String concatentation.
Or even better yet, don't build up markup in strings! Either use a template system like JSP, or if you must build markup in Java, explore the use of packages like Jakarta ECS that allow you to build a DOM representing your markup as objects, and then serialize it to html, xhtml or other markup.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
Note that if you concatenate string CONSTANTS, the compiler shoves them all together as one big string. So concatenation can be used at no cost to make long string constants more readable, as in:

which compiles to exactly the same bytecodes as:

Using StringBuffer.append in the above situation would be less readable and acutally less efficient:


Note also that non-constant string concatenation on a single line of code compiles to a usage of StringBuffer. The following two lines of code compile to identical bytecodes (JDK 1.4 - others are similar):

Actually, in many cases, using String.concat() can be more efficient (faster and creates fewer objects) than the above StringBuffer gunk, as in:

Just in case you wanted to know....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: illegal character: \92
 
Similar Threads
validation - depends on the circumstances
Deployment issue
return false still submit the page in IE
Error 92
I think I need this