All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jflyfox.util.PathUtils Maven / Gradle / Ivy

package com.jflyfox.util;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

/**
 * 路径处理工具
 * 
 * 2016年6月2日 下午3:52:05
 * flyfox [email protected]
 */
public class PathUtils {

	private static final String DEFAULT_CHARSET = "UTF-8";
	
	public static String rebuild(String path) {
		String newPath = path;
		try {
			newPath =  URLDecoder.decode(newPath, DEFAULT_CHARSET);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		newPath = rebuildNoDecode(newPath);
		
		return newPath;
	}
	
	public static String rebuildNoDecode(String path) {
		String newPath = path;
		newPath = newPath.replaceAll("\\\\", "/");
		newPath = newPath.replaceAll("//", "/");
		
		return newPath;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy