Java Path String Clean cleanPath(String loc)

Here you can find the source of cleanPath(String loc)

Description

clean Path

License

Open Source License

Declaration

private static String cleanPath(String loc) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010-2014 ITER Organization.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/

public class Main {
    private static String cleanPath(String loc) {

        // Remove reference:file: from the start. TODO find a better way,
        // and test that this works on windows (it might have ///)
        if (loc.startsWith("reference:file:")) {
            loc = loc.substring(15);/* w ww.  j  a v a  2  s .co m*/
        } else if (loc.startsWith("file:")) {
            loc = loc.substring(5);
        } else {
            return loc;
        }

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

        return loc;
    }
}

Related

  1. cleanPath(final String path)
  2. cleanPath(final String url)
  3. cleanPath(String path)
  4. cleanPath(String path)
  5. cleanPath(String path)
  6. cleanPath(String path)