简体   繁体   中英

how to save a path in database with backslashes?

i'm developing a java application using jdbc,mySQL,Query browser. I want to save an image path in my db. after i save it, it shows, "C:UsersabcDesktop1.png". But I want the path as, "C:\\Users\\abc\\Desktop\\1.png" how to do this?

If you want your code to be portable under another linux system one day, you should use / as File separator so save as C:/Users/abc/Desktop/1.png .

Java would retrieve the file anyway at the correct path

`"C:\\\\Users\\\\abc\\\\Desktop\\\\1.png"

You should write it like this.

A \\ is used Escape Sequences like \\n \\r etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM