It's not a secret anymore!
The moose likes Beginning Java and the fly likes especial characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "especial characters" Watch "especial characters" New topic

especial characters

Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 104

Hello I would like to get a String value will be ="C:\file.txt";

DocumentacionCategoriaDto documentacionCategoriaDto= documentacionCategoriaModel.getDocumento(idDocumento);
ruta = documentacionCategoriaDto.getRutaDoc() + "\\" + documentacionCategoriaDto.getNombreDoc();

By this way compiler doesn't complain

System.out shows C:\file.txt

But debbuger says that ruta's value is "c:\\file.txt"
if I only use "\" eclipse complains.

Howe can I get C:\file.txt

Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
Certain charactors in a string have special meaning, and are called escape charactors, to create these escape charactors a \ is used thus, if you wish to use \ in a string you most escape it, making: \\

thus c:\\file.txt will be printed on screen as c:\file.txt

you could also try using unix like seprators ie c:/file.txt

[ June 19, 2007: Message edited by: Gavin Tranter ]
[ June 19, 2007: Message edited by: Gavin Tranter ]
Sasha Ruehmkorf
Ranch Hand

Joined: Mar 29, 2007
Posts: 115
I don't see the problem with your solution, but you could also try:

[ June 19, 2007: Message edited by: Sasha Ruehmkorf ]
I agree. Here's the link:
subject: especial characters
It's not a secret anymore!