Here you can find the source of cleanPath(String loc)
public static String cleanPath(String loc)
//package com.java2s; /*//from w w w . j a v a 2s . c o m * Copyright (c) 2012 Diamond Light Source Ltd. * * 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 */ import java.io.File; import java.util.Locale; public class Main { public 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); } else if (loc.startsWith("file:")) { loc = loc.substring(5); } else { return loc; } loc = loc.replace("//", "/"); loc = loc.replace("\\\\", "\\"); boolean isWindows = System.getProperty("os.name").toUpperCase(Locale.ENGLISH).contains("WINDOWS") && (File.separatorChar == '\\'); if (isWindows && loc.startsWith("/")) { loc = loc.substring(1); } return loc; } }