This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

illegal space character  RSS feed

 
memati bas
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
While I am creating A File object, I encounter an compile error.

It says that I used an illegal character. How can I fix it ??
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With Java strings, the "\" is an escape character. When combined with the next character, it has special meaning. In your case, you actually want the backslash...

File myFile = new File("C:\\Program Files\\Java\\jdk1.5.0\\bin");

Henry
 
tapan hoskeri
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is with the single backslash characters used in the path you have specified. You will have to 'escape' the single backslash 'special character' with another backslash. The below line should work...

File myFile = new File("C:\\Program Files\\Java\\jdk1.5.0\\bin");
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!