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 What is illegal escape character in java 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 "What is illegal escape character in java" Watch "What is illegal escape character in java" New topic
Author

What is illegal escape character in java

sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear Sir,
While complile this code the error message display that "Illegal escape character".Please guide me to rectify this code.

The data.txt file contains:->Sumanta,Sagar,Harish



Thanks and Regards
Sumanta Panda
[ November 21, 2008: Message edited by: Martijn Verburg ]
Miklos Szeles
Ranch Hand

Joined: Oct 21, 2008
Posts: 142
Hi,

I think you should write



If you want to write a \ in a String literal you have to write \\, anyway Java compiler interprets it as an escape character. Since no such escape characters as \T or \d the java compiler reports an error.
Regards,
Miki
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Miklos is indeed correct, shifting to the beginners forum, more people will gain benefit from this if they search there.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Another option is using forward slashes. File is smart enough to convert those to backslashes when accessing the actual file system.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11169
    
  16

Generally speaking, when the compiler gives you an error message, it tells you more than just "illegal escape character". It will show you the line and even the exact spot it thinks the error actually is:


It GREATLY helps people help you if you post the ENTIRE message. This lets a reader instantly focus in on where the problem is, rather than having to parse you entire java file and GUESS.

Just a little helpful tip for next time.
[ November 21, 2008: Message edited by: fred rosenberger ]

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
zameel amjed
Greenhorn

Joined: Feb 16, 2011
Posts: 14

And check letter case at the readLine method it should be:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is illegal escape character in java
 
Similar Threads
How to display the retrive data in select drop down list.
How will i pass the SubjectofIssuePath in File fin=new File();
How to display the retrive data in select drop down list.
How to display the retrive data in select drop down list
split(String) problem in my jsp