检查文件路径是否存在

@param path 文件路径

@return 文件的绝对路径，如果文件存在，则生成一个新路径
160902
private static String checkPath(String path) {
        File file = new File(path);
        int idx = path.lastIndexOf(".");
        String post = "";
        if (idx > -1) {
            post = path.substring(idx);
            path = path.substring(0, idx);
        }
        int i = 0;
        while (file.exists()) {
            file = new File(path + "_" + (++i) + post);
        }
        return file.getAbsolutePath();
    }
152611
public File getBackupFile(String path) {

		String rootDir = tempDir + JawrConstant.SPRITE_BACKUP_GENERATED_CSS_DIR;
		String fPath = null;
		if (jawrConfig.isWorkingDirectoryInWebApp()) {
			fPath = jawrConfig.getContext().getRealPath(rootDir + getCssPath(path));
		} else {
			fPath = rootDir + getCssPath(path);
		}

		return new File(fPath);
	}
662803
public synchronized com.sun.tools.javac.util.List<String> getFiles(RelativeDirectory path) {
        try {
            checkIndex();

            DirectoryEntry de = directories.get(path);
            com.sun.tools.javac.util.List<String> ret = de == null ? null : de.getFiles();

            if (ret == null) {
                return com.sun.tools.javac.util.List.<String>nil();
            }
            return ret;
        }
        catch (IOException e) {
            return com.sun.tools.javac.util.List.<String>nil();
        }
    }
767027
public static String createFolderPath(String path) {

        String[] pathParts = path.split("\\.");
        String path2 = "";
        for (String part : pathParts) {
            if (path2.equals("")) {
                path2 = part;
            } else {
                path2 = path2 + File.separator
                        + changeFirstLetterToLowerCase(createClassName(part));
            }
        }

        return path2;
    }
374195
public StringPath get(StringPath path) {
        StringPath newPath = getString(toString(path));
        return addMetadataOf(newPath, path);
    }
1187728
public static Map<String, String> read(final String path) {

        Map<String, String> map = new HashMap<String, String>();

        if (path != null) {
            try {
                Properties p = loadProperties(path);

                for (Object key : p.keySet()) {

                    String value = p.getProperty(String.valueOf(key));

                    // remove single/double quotes
                    if ((value.startsWith("\"") && value.endsWith("\"")) ||
                            (value.startsWith("\'") && value.endsWith("\'"))) {
                        value = value.substring(1, value.length() - 1);
                    }

                    value = value.trim();

                    if (!value.equals("")) {
                        map.put(String.valueOf(key), value);
                    }
                }

            } catch (Exception e) {
                log.error(e.getMessage(), e);
            }
        }

        return map;
    }
802302
public String getUploadFileUrl(String path) {
        final StringBuilder sb = new StringBuilder(GWT.getModuleBaseURL() + UPLOAD_SERVLET_URL);
        sb.append("?").append("path").append("=").append(URL.encode(path));
        return sb.toString();
    }
1280623
public static String filepath2URI(String path){
        // return null if path is null.
        if (path == null)
            return null;

        char separator = java.io.File.separatorChar;
        path = path.replace(separator, '/');

        int len = path.length(), ch;
        StringBuilder buffer = new StringBuilder(len*3);
        buffer.append("file://");
        // change C:/blah to /C:/blah
        if (len >= 2 && path.charAt(1) == ':') {
            ch = Character.toUpperCase(path.charAt(0));
            if (ch >= 'A' && ch <= 'Z') {
                buffer.append('/');
            }
        }

        // for each character in the path
        int i = 0;
        for (; i < len; i++) {
            ch = path.charAt(i);
            // if it's not an ASCII character, break here, and use UTF-8 encoding
            if (ch >= 128)
                break;
            if (gNeedEscaping[ch]) {
                buffer.append('%');
                buffer.append(gAfterEscaping1[ch]);
                buffer.append(gAfterEscaping2[ch]);
                // record the fact that it's escaped
            }
            else {
                buffer.append((char)ch);
            }
        }

        // we saw some non-ascii character
        if (i < len) {
            // get UTF-8 bytes for the remaining sub-string
            byte[] bytes = null;
            byte b;
            try {
                bytes = path.substring(i).getBytes("UTF-8");
            } catch (java.io.UnsupportedEncodingException e) {
                // should never happen
                return path;
            }
            len = bytes.length;

            // for each byte
            for (i = 0; i < len; i++) {
                b = bytes[i];
                // for non-ascii character: make it positive, then escape
                if (b < 0) {
                    ch = b + 256;
                    buffer.append('%');
                    buffer.append(gHexChs[ch >> 4]);
                    buffer.append(gHexChs[ch & 0xf]);
                }
                else if (gNeedEscaping[b]) {
                    buffer.append('%');
                    buffer.append(gAfterEscaping1[b]);
                    buffer.append(gAfterEscaping2[b]);
                }
                else {
                    buffer.append((char)b);
                }
            }
        }

        return buffer.toString();
    }
1082372
public static final String posixString(Path path)
    {
        String prefix = path.isAbsolute() ? "/" : "";
        String suffix = Files.isDirectory(path) ? "/" : "";
        return StreamSupport.stream(path.spliterator(), false)
                .map((p)->p.toString())
                .collect(Collectors.joining("/", prefix, suffix));
    }
1242862
public static String getScript(String path) {
        StringBuilder sb = new StringBuilder();

        InputStream stream = ScriptUtil.class.getClassLoader().getResourceAsStream(path);
        try (BufferedReader br = new BufferedReader(new InputStreamReader(stream))){

            String str;
            while ((str = br.readLine()) != null) {
                sb.append(str).append(System.lineSeparator());
            }

        } catch (IOException e) {
            System.err.println(e.getStackTrace());
        }
        return sb.toString();
    }
903313
public static String generateOutputFilePath(String path, String fileName) {
		String tempPath = separatorsToSystem(path);
		tempPath = tempPath + File.separatorChar + fileName;
		return tempPath;
	}
662009
public static InputStream asInputStream(Path path) throws IOException {
		Validate.notNull(path, "path is null");
		return Files.newInputStream(path);
	}
352132
private String normalizePath(String path) {
		// 标准化路径
		path = FileUtil.normalize(path);
		path = StrUtil.removePrefix(path, StrUtil.SLASH);

		Assert.isFalse(FileUtil.isAbsolutePath(path), "Path [{}] must be a relative path !", path);
		return path;
	}
472809
public Optional<InputStream> getResourceAsStream(String path) {
        if (!isDirectory(path)) {
            return Optional.ofNullable(classLoader.getResourceAsStream(prefixPath(path)));
        }
        return Optional.empty();
    }
112864
public FTPFile[] lsFiles(String path){
		String pwd = null;
		if(StrUtil.isNotBlank(path)) {
			pwd = pwd();
			cd(path);
		}
		
		FTPFile[] ftpFiles;
		try {
			ftpFiles = this.client.listFiles();
		} catch (IOException e) {
			throw new FtpException(e);
		}
		
		if(StrUtil.isNotBlank(pwd)) {
			// 回到原目录
			cd(pwd);
		}
		
		return ftpFiles;
	}
1002785
public static ByteArray createByteArray(String path)
    {
        byte[] bytes = IOUtil.readBytes(path);
        if (bytes == null) return null;
        return new ByteArray(bytes);
    }
1011741
public void addFile(String path) throws LoadModelException{
		try {
			ArrayList<String[]> al = loadDict(path);		
			add(al); 
			indexLen = MIN_LEN;
			createIndex();
		} catch (IOException e) {
			throw new LoadModelException("加载词典错误"+e.toString());
		}
	}