convert path to UNIX path

Convert all backward slashes into forward slashes.

Download tounixpath.zip

Synopsis:

tounixpath.java


tounixpath.java

Synopsis
package jsnippets;
import utjava.ut;

public class tounixpath
{
  public String toUnixPath(String path)
  {
    return path.replace('\\', '/');
  }

  public void test_identities()
  {
    ut.utassert(toUnixPath(""), "");
    ut.utassert(toUnixPath("x"), "x");
    ut.utassert(toUnixPath("c:/x"), "c:/x");
  }

  public void test_1()
  {
    ut.utassert(toUnixPath("x\\y"), "x/y");
    ut.utassert(toUnixPath("\\y"), "/y");
    ut.utassert(toUnixPath("x\\"), "x/");
    ut.utassert(toUnixPath("c:x\\"), "c:x/");
    ut.utassert(toUnixPath("\\"), "/");
  }
}






Contact me about content on this page using john_web-at-arrizza-dot-com
For Web Master or site problems contact: webadmin-at-arrizza-dot-com
Copyright John Arrizza (c) 2001,2002,2003,2004,2005,2006,2007