How to replace backward slash to forward slash using java?

前端 未结 3 714
难免孤独
难免孤独 2020-12-01 10:18

I\'m importing a CSV file to MySQL database. This can be done using java.mysql support for forward slash in file path. If user gives the path

c         


        
3条回答
  •  甜味超标
    2020-12-01 11:13

    In java, use this:

    str = str.replace("\\", "/");
    

    Note that the regex version of replace, ie replaceAll(), is not required here; replace() still replaces all occurrences of the search term, but it searches for literal Strings, not regex matches.

提交回复
热议问题