简体   繁体   English

如何使用反斜杠在数据库中保存路径?

[英]how to save a path in database with backslashes?

i'm developing a java application using jdbc,mySQL,Query browser.我正在使用 jdbc、mySQL、Query 浏览器开发一个 java 应用程序。 I want to save an image path in my db.我想在我的数据库中保存一个图像路径。 after i save it, it shows, "C:UsersabcDesktop1.png".保存后,它显示“C:UsersabcDesktop1.png”。 But I want the path as, "C:\\Users\\abc\\Desktop\\1.png" how to do this?但我想要路径为“C:\\Users\\abc\\Desktop\\1.png”怎么做?

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 .如果有一天你希望你的代码在另一个 linux 系统下可移植,你应该使用/作为文件分隔符,以便保存为C:/Users/abc/Desktop/1.png

Java would retrieve the file anyway at the correct path Java 无论如何都会在正确的路径中检索文件

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

You should write it like this.你应该这样写。

A \\ is used Escape Sequences like \\n \\r etc. \\ 用于转义序列,如 \\n \\r 等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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