Dave's Brain

Browse - Programming Tips - How can I convert a path to for Linux-style forward slashes

Date: 2014jan12
Language: Java

Q.  How can I convert a path to for Linux-style forward slashes
or Windows-style backward slashes?    

A.

String toForwardSlashes(String s) { return s.replace("\\", "/"); } String toBackwardSlashes(String s) { return s.replace("/", "\\"); }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.