Append and close path.

@param filePath      the file path
@param charset       the charset
@param writingString the writing string
@return the path
496310
public static Path appendAndClose(String filePath, Charset charset,
            String writingString) {
        return new JMFileAppender(filePath, charset).append(writingString)
                .closeAndGetFilePath();
    }
26621
public static Optional<String> getStringAsOptWithFilePath(
            String filePath, String charsetName) {
        return JMOptional
                .getOptional(JMFiles.readString(filePath, charsetName));
    }
442141
public static <T> File writeLines(Collection<T> list, String path, String charset, boolean isAppend) throws IORuntimeException {
		return writeLines(list, file(path), charset, isAppend);
	}
319079
public static void append(Path self, Object text) throws IOException {
        Writer writer = null;
        try {
            writer = new OutputStreamWriter(Files.newOutputStream(self, CREATE, APPEND), Charset.defaultCharset());
            InvokerHelper.write(writer, text);
            writer.flush();

            Writer temp = writer;
            writer = null;
            temp.close();
        } finally {
            closeWithWarning(writer);
        }
    }
1103297
public String readFileAsString(String filePath) 
	    throws IOException {
	    
		String result = null;
		Reader reader = new BufferedReader(new FileReader(filePath));

		StringBuilder stringBuffer = new StringBuilder(4096);
		int charRead = -1;
		while ((charRead = reader.read()) >= 0) {
			stringBuffer.append((char) charRead);
		}

		reader.close();
		result = stringBuffer.toString();
		return result;
	}
915082
public static Resource getFileResource(String filePath) {
        String path;

        if (filePath.contains(FILE_PATH_CHARSET_PARAMETER)) {
            path = filePath.substring(0, filePath.indexOf(FileUtils.FILE_PATH_CHARSET_PARAMETER));
        } else {
            path = filePath;
        }

        if (path.startsWith(ResourceUtils.FILE_URL_PREFIX)) {
            return new FileSystemResource(path.substring(ResourceUtils.FILE_URL_PREFIX.length() - 1));
        } else if (path.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) {
            return new PathMatchingResourcePatternResolver().getResource(path);
        }

        Resource file = new FileSystemResource(path);
        if (!file.exists()) {
            return  new PathMatchingResourcePatternResolver().getResource(path);
        }

        return file;
    }
403888
static String encodePath(String content, Charset charset) {
        final StringBuilder buf = new StringBuilder();
        final ByteBuffer bb = charset.encode(content);
        while (bb.hasRemaining()) {
            final int b = bb.get() & 0xff;
            if (PATHSAFE.get(b)) {
                buf.append((char) b);
            } else {
                buf.append("%");
                final char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX));
                final char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX));
                buf.append(hex1);
                buf.append(hex2);
            }
        }
        return buf.toString();
    }
785714
public void addFile(String path, InputStream inputStream, String contentType) throws IOException {
    String fullPath = buildJcrPathForZip(path);
    writeBinaryFile(fullPath, inputStream);

    if (StringUtils.isNotEmpty(contentType)) {
      String mimeType = StringUtils.substringBefore(contentType, CONTENT_TYPE_CHARSET_EXTENSION);
      String encoding = StringUtils.substringAfter(contentType, CONTENT_TYPE_CHARSET_EXTENSION);

      String fullPathMetadata = fullPath + DOT_DIR_FOLDER + "/" + DOT_CONTENT_XML;
      Document doc = xmlContentBuilder.buildNtFile(mimeType, encoding);
      writeXmlDocument(fullPathMetadata, doc);
    }
  }
271872
private static String fileAsString(String path) throws Exception {
        StringBuffer buffer = new StringBuffer();
        InputStream fis = new FileInputStream(path);
        InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
        Reader in = new BufferedReader(isr);
        int ch;
        while ((ch = in.read()) > -1) {
            buffer.append((char) ch);
        }
        in.close();
        return buffer.toString();
    }
479712
public static boolean createFile(String filePath) {
        if (!StringUtils.isEmpty(filePath)) {
            File file = new File(filePath);
            return createFile(file);
        }
        return false;
    }
183415
public static File appendString(String content, String path, String charset) throws IORuntimeException {
		return appendString(content, touch(path), charset);
	}
793238
private static void appendPath(QPath relPath, StringBuilder buffer) {
         QPathEntry[] elements = relPath.getEntries();
        String slash = "";
        for (int i = 0; i < elements.length; i++) {
            buffer.append(slash);
            slash = "/";
            buffer.append(elements[i].getAsString(true));
        }
    }
622737
public static File writeStringToTempFile(String contents, String path, String encoding) throws IOException {
		OutputStream writer = null;
		File tmp = File.createTempFile(path,".tmp");
		if (path.endsWith(".gz")) {
			writer = new GZIPOutputStream(new FileOutputStream(tmp));
		} else {
			writer = new BufferedOutputStream(new FileOutputStream(tmp));
		}
		writer.write(contents.getBytes(encoding));
		writer.close();
		return tmp;
	}
1338619
public static Path appendLinesAndClose(String filePath, Charset charset,
            Collection<String> lineCollection) {
        return appendLineStreamAndClose(filePath, charset,
                lineCollection.stream());
    }
662451
public static void closeWriter(String filePath) {
        Writer writer = writerCache.get(filePath);
        if (writer != null) {
            try {
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        writerCache.remove(writer);
    }
751056
public static StorePath parseFromUrl(String filePath) {
        Validate.notNull(filePath, "解析文件路径不能为空");

        String group = getGroupName(filePath);

        // 获取group起始位置
        int pathStartPos = filePath.indexOf(group) + group.length() + 1;
        String path = filePath.substring(pathStartPos, filePath.length());
        return new StorePath(group, path);
    }
515853
public void addFile(String filename, String filePath) {
        int pathIndex = filePathList.indexOf(filePath);
        if (pathIndex == -1) {
            fileNameList.add(filename);
            filePathList.add(filePath);
        }
    }