Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

especial characters

 
Ranch Hand
Posts: 111
Eclipse IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello I would like to get a String value will be ="C:\file.txt";

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

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

Thanks
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see the problem with your solution, but you could also try:

[ June 19, 2007: Message edited by: Sasha Ruehmkorf ]
 
Well behaved women rarely make history - Eleanor Roosevelt. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic