创建文件及其父目录，如果这个文件存在，直接返回这个文件<br>
此方法不对File对象类型做判断，如果File不存在，无法判断其类型

@param fullFilePath 文件的全路径，使用POSIX风格
@return 文件，若路径为null，返回null
@throws IORuntimeException IO异常
773437
public static File touch(String fullFilePath) throws IORuntimeException {
		if (fullFilePath == null) {
			return null;
		}
		return touch(file(fullFilePath));
	}
1063620
private File findPathResource(@NonNull String httpPath) {
        if ("/".equals(httpPath)) {
            File indexFile = new File(mRootPath, getIndexFileName());
            if (indexFile.exists() && indexFile.isFile()) {
                return indexFile;
            }
        } else {
            File sourceFile = new File(mRootPath, httpPath);
            if (sourceFile.exists()) {
                if (sourceFile.isFile()) {
                    return sourceFile;
                } else {
                    File childIndexFile = new File(sourceFile, getIndexFileName());
                    if (childIndexFile.exists() && childIndexFile.isFile()) {
                        return childIndexFile;
                    }
                }
            }
        }
        return null;
    }
748444
public static BufferedReader getReader(Path path, Charset charset) throws IORuntimeException {
		return IoUtil.getReader(getInputStream(path), charset);
	}
857810
public static Message buildFileReceived(String fullPath) {
    ZabMessage.FileReceived received = ZabMessage.FileReceived
                                                 .newBuilder()
                                                 .setFullPath(fullPath)
                                                 .build();
    return Message.newBuilder().setType(MessageType.FILE_RECEIVED)
                               .setFileReceived(received).build();
  }
143293
public static File getFileForResource(final String resourcePath) {
        URL path = ResourceUtil.class.getResource(resourcePath);
        if (path == null) {
            path = ResourceUtil.class.getResource("/");
            return new File(new File(path.getPath()), resourcePath);
        }

        return new File(path.getPath());
    }
147851
public static void writeToStream(String fullFilePath, OutputStream out) throws IORuntimeException {
		writeToStream(touch(fullFilePath), out);
	}
1318842
public static List<String> listFileNames(String path) throws IORuntimeException {
		if (path == null) {
			return null;
		}
		List<String> paths = new ArrayList<String>();

		int index = path.lastIndexOf(FileUtil.JAR_PATH_EXT);
		if (index == -1) {
			// 普通目录路径
			File[] files = ls(path);
			for (File file : files) {
				if (file.isFile()) {
					paths.add(file.getName());
				}
			}
		} else {
			// jar文件
			path = getAbsolutePath(path);
			if (false == StrUtil.endWith(path, UNIX_SEPARATOR)) {
				path = path + UNIX_SEPARATOR;
			}
			// jar文件中的路径
			index = index + FileUtil.JAR_FILE_EXT.length();
			JarFile jarFile = null;
			try {
				jarFile = new JarFile(path.substring(0, index));
				final String subPath = path.substring(index + 2);
				for (JarEntry entry : Collections.list(jarFile.entries())) {
					final String name = entry.getName();
					if (name.startsWith(subPath)) {
						final String nameSuffix = StrUtil.removePrefix(name, subPath);
						if (false == StrUtil.contains(nameSuffix, UNIX_SEPARATOR)) {
							paths.add(nameSuffix);
						}
					}
				}
			} catch (IOException e) {
				throw new IORuntimeException(StrUtil.format("Can not read file path of [{}]", path), e);
			} finally {
				IoUtil.close(jarFile);
			}
		}
		return paths;
	}
1266963
public static String readFileContentToString(String filePath)
            throws IOException {
        String content = "";
        content = Files.toString(new File(filePath), Charsets.UTF_8);
        return content;
    }
888203
public static void compressList(String srcFilePath, String destFilePath) throws Exception {
		File src = new File(srcFilePath);
		if (!src.exists() || !src.isDirectory()) {
			throw new RuntimeException(srcFilePath + "不存在");
		}
		File zipFile = new File(destFilePath);
		ZipOutputStream zos=null;
		try {
			FileOutputStream fos = new FileOutputStream(zipFile);
			CheckedOutputStream cos = new CheckedOutputStream(fos, new CRC32());
			zos = new ZipOutputStream(cos);
			String baseDir = "";
			File[] files = src.listFiles();
			for (File file : files) {
				compressbyType(file, zos, baseDir);
			}			
		} finally {
			if(zos!=null)
			{
				zos.close();
			}
		}
	}
67347
public static boolean del(File file) throws IORuntimeException {
		if (file == null || false == file.exists()) {
			// 如果文件不存在或已被删除，此处返回true表示删除成功
			return true;
		}

		if (file.isDirectory()) {
			// 清空目录下所有文件和目录
			boolean isOk = clean(file);
			if (false == isOk) {
				return false;
			}
		}

		// 删除文件或清空后的目录
		return file.delete();
	}
638498
public static String getType(File file) throws IORuntimeException {
		FileInputStream in = null;
		try {
			in = IoUtil.toStream(file);
			return getType(in);
		} finally {
			IoUtil.close(in);
		}
	}
769519
public static synchronized String getAbsolutePath(String path) {
		try {
			if (rootDir == null) {
				Class<?> parentClass = getParentClass();
				String classFile = parentClass.getName().replace('.', '/') + ".class";
				URL url = parentClass.getResource("/" + classFile);
				if (url == null) {
					return null;
				}
				if (url.getProtocol().equals("jar")) {
					rootDir = url.getPath();
					int i = rootDir.lastIndexOf('!');
					if (i >= 0) {
						rootDir = rootDir.substring(0, i);
					}
					rootDir = new File(new URL(rootDir).toURI()).getParent();
				} else {
					rootDir = new File(url.toURI()).getPath();
					rootDir = rootDir.substring(0, rootDir.length() - classFile.length());
					if (rootDir.endsWith(File.separator)) {
						rootDir = rootDir.substring(0, rootDir.length() - 1);
					}
				}
				rootDir = new File(rootDir).getParent();
			}
			return new File(rootDir + File.separator + path).getCanonicalPath();
		} catch (IOException | URISyntaxException e) {
			throw new RuntimeException(e);
		}
	}
43282
public static File getFileFromDirectoryInClassPath(String fileName, String classPath) {

		Collection<String> paths = StringSupport.split(classPath, ";:", false);

		for(String singlePath : paths) {
			File dir = new File(singlePath);
			if (dir.isDirectory()) {
				File file = new File(singlePath + '/' + fileName);
				if (file.exists()) {
					return file;
				}
			}
		}
		return null;
	}
812992
public static File appendUtf8String(String content, String path) throws IORuntimeException {
		return appendString(content, path, CharsetUtil.CHARSET_UTF_8);
	}
190905
public static String getFileName(String fullPath) {
        Preconditions.checkNotNull(fullPath, "path can not be null");
        int winDelimiterPos = fullPath.lastIndexOf(WINDOWS_DELIMITER);
        int linDelimiterPos = fullPath.lastIndexOf(LINUX_DELIMITER);
        int pos = Math.max(winDelimiterPos, linDelimiterPos);
        return fullPath.substring(pos + 1, fullPath.length());
    }
777140
public static Properties readPropertiesFromClasspathFile(String fullPath) {
        Properties properties = new Properties();
        try (InputStream inputStream = readClasspathFileIntoStream(fullPath)) {
            properties.load(new InputStreamReader(inputStream));
        } catch (IOException e) {
            throw new RuntimeException("加载配置文件" + fullPath + "出错");
        }
        return properties;
    }
893380
public FileStatus getFileStatus (Path f) throws IOException {
    try (Closeable context = new TimerContextWithLog(this.getFileStatusTimer.time(), "getFileStatus", f)) {
      return super.getFileStatus(f);
    }
  }