public abstract class IOUtil extends Object
| 构造器和说明 |
|---|
IOUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static long |
copyInToOut(InputStream from,
OutputStream to)
把InputStream复制到OutputStream
|
static void |
createFile(String fileName,
long fileSize)
创建指定大小的文件
|
static InputStream |
fileToInputStream(String filePath,
Class classz)
通过class加载文件
|
static Properties |
fileToProperties(File filePath)
文件转为prop
|
static Properties |
fileToProperties(String filePath)
classpath的属性文件转为属性
|
static Properties |
fileToProperties(String filePath,
Class classz)
属性文件转为属性
|
static List<String> |
getClassNameFromDir(String classDir,
String packageName)
指定目录下的class文件
|
static List<String> |
getClassNameFromJar(String jarUrlStr,
String filtDirPath)
从jar文件里得到指定目录下的class名
|
static File |
getCurFolder()
得到当前目录 ,不打jar: file:/D:/source/github/commons/target/classes/
打jar:jar所在目录:E:\binlog
|
static String |
getDirForCommonUtilFilePath(String filePath)
得到此项目下的文件目录路径
|
static String |
getDirForFilePath(Class classStr,
String filePath)
得到指定Class下的文件的目录
|
static Map<String,InputStream> |
getFilesFromJar(String jarUrlStr,
String dirPath)
查找jar中的某个目录下的所有文件
\D:\greensoft\maven\repository\com\zhongan\plugins\za-maven-plugin\0.1\za
-maven-plugin-0.1.jar!
|
static List<String> |
getSubType(String filepath,
String packageName,
String parentClassName,
javassist.ClassPool pool) |
static List<String> |
getSubTypeFromDir(String classDir,
String packageName,
String parentClassName,
javassist.ClassPool pool)
得到指定目录下的指定class的子class
|
static List<String> |
getSubTypeFromJar(String jarUrlStr,
String dirPath,
String parentClassName,
javassist.ClassPool pool)
得到jar里面指定class的子class
|
static JarFile |
jarRead(String jarUrlStr) |
static String |
mergeFolderAndFilePath(String folderPath,
String fileName)
合并目录与文件名
|
static List<String> |
readFileReverse(String filename,
int maxNum) |
static List<String> |
readFileReverse(String filename,
int maxNum,
String charset,
boolean isKipnull) |
static void |
replaceDir(String oriPath,
String destPath,
String... replaceRule)
按规则替换整个目录下的文件
|
static void |
replaceFile(String oriPath,
String destPath,
Encoding oriEncoding,
Encoding destEncoding,
String... replaceRule)
把源模板文件替换为符合条件的目的文件
|
static void |
replaceFile(String oriPath,
String destPath,
String... replaceRule)
把源模板文件替换为符合条件的目的文件,用UTF-8编码
|
static void |
replaceFileByStr(String oriContext,
BasePath basePath,
String relaPath,
String... replaceRule)
代码文件内容并写文件,用UTF-8方法
|
static void |
replaceFileByStr(String oriContext,
String destPath,
Encoding oriEncoding,
Encoding destEncoding,
String... replaceRule)
代码文件内容并写文件
|
static void |
replaceFileByStr(String oriContext,
String destPath,
String... replaceRule)
代码文件内容并写文件,用UTF-8方法
|
static String |
slurp(InputStream in) |
static String |
slurp(InputStream in,
Encoding oriEncoding)
转换输入流为字符串
|
static void |
subClassFilter(List<String> allClassName,
String parentClassName,
javassist.ClassPool pool) |
public static String slurp(InputStream in, Encoding oriEncoding) throws IOException
in - 输入流oriEncoding - 源编码格式IOException - 转换出错public static String slurp(InputStream in) throws IOException
IOExceptionpublic static Properties fileToProperties(String filePath, Class classz)
filePath - 文件路径classz - 要加载属性文件同jar包的类public static Properties fileToProperties(File filePath)
filePath - 属性文件public static InputStream fileToInputStream(String filePath, Class classz)
filePath - 文件所在路径classz - 文件所在jar包中的class名public static Properties fileToProperties(String filePath)
filePath - 文件路径public static String mergeFolderAndFilePath(String folderPath, String fileName)
folderPath - 目录路径fileName - 文件名public static String getDirForFilePath(Class classStr, String filePath)
classStr - 指定的classfilePath - 文件的相对路径public static String getDirForCommonUtilFilePath(String filePath)
filePath - 文件路径public static long copyInToOut(InputStream from, OutputStream to) throws IOException
from - 输入流to - 输出流IOException - 操作异常public static void replaceFile(String oriPath, String destPath, Encoding oriEncoding, Encoding destEncoding, String... replaceRule) throws IOException
oriPath - 源文件路径destPath - 目标文件路径oriEncoding - 源文件编码destEncoding - 目标文件编码replaceRule - 替换规则IOException - IO异常public static void replaceFileByStr(String oriContext, String destPath, Encoding oriEncoding, Encoding destEncoding, String... replaceRule) throws IOException
oriContext - 要处理的文件内容destPath - 目标文件路径oriEncoding - 源文件编码destEncoding - 目标文件编码replaceRule - 替换规则IOException - IO异常public static void replaceFileByStr(String oriContext, String destPath, String... replaceRule) throws IOException
oriContext - 要处理的文件内容destPath - 目标文件路径replaceRule - 替换规则IOException - IO异常public static void replaceFileByStr(String oriContext, BasePath basePath, String relaPath, String... replaceRule) throws IOException
oriContext - 要处理的文件内容basePath - 基础路径relaPath - 相对路径replaceRule - 替换规则IOException - IO异常public static void replaceFile(String oriPath, String destPath, String... replaceRule) throws IOException
oriPath - 源文件路径destPath - 目标文件路径replaceRule - 替换规则IOException - IO异常public static void replaceDir(String oriPath, String destPath, String... replaceRule) throws IOException
oriPath - 源路径destPath - 目的路径replaceRule - 替换规则IOException - IO异常public static Map<String,InputStream> getFilesFromJar(String jarUrlStr, String dirPath) throws Exception
jarUrlStr - jar文件路径dirPath - jar里的目录路径Exception - 读文件异常public static JarFile jarRead(String jarUrlStr) throws MalformedURLException, IOException
public static List<String> getClassNameFromJar(String jarUrlStr, String filtDirPath) throws Exception
jarUrlStr - jar文件路径filtDirPath - jar里的目录路径Exception - 读文件异常public static List<String> getClassNameFromDir(String classDir, String packageName)
classDir - class的目录路径packageName - 指定的的包目录public static List<String> getSubTypeFromJar(String jarUrlStr, String dirPath, String parentClassName, javassist.ClassPool pool) throws Exception
jarUrlStr - jar文件路径dirPath - jar里的目录路径parentClassName - 父类的类名pool - 类池Exception - 读文件异常public static List<String> getSubTypeFromDir(String classDir, String packageName, String parentClassName, javassist.ClassPool pool) throws Exception
classDir - 类目录packageName - 类目录下的包名parentClassName - 指定父类pool - 类池Exception - 读文件异常public static List<String> getSubType(String filepath, String packageName, String parentClassName, javassist.ClassPool pool) throws Exception
Exceptionpublic static void subClassFilter(List<String> allClassName, String parentClassName, javassist.ClassPool pool) throws javassist.NotFoundException
javassist.NotFoundExceptionpublic static File getCurFolder()
public static List<String> readFileReverse(String filename, int maxNum, String charset, boolean isKipnull)
public static void createFile(String fileName, long fileSize) throws IOException
fileName - 文件名fileSize - 文件大小IOException - 创建文件异常Copyright © 2017. All rights reserved.