Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is illegal escape character in java

 
sumanta panda
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 142
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miklos is indeed correct, shifting to the beginners forum, more people will gain benefit from this if they search there.
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another option is using forward slashes. File is smart enough to convert those to backslashes when accessing the actual file system.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12198
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
zameel amjed
Greenhorn
Posts: 14
Notepad PHP Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And check letter case at the readLine method it should be:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic