Package cn.toutatis.xvoid.toolkit.file
Object FileToolkit
-
- All Implemented Interfaces:
public class FileToolkit文件相关工具
Toutatis_Gc
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringTEMP_FILE_DIRpublic final static StringRESOURCE_FILE_DIRpublic final static FileToolkitINSTANCE
-
Method Summary
Modifier and Type Method Description final static BooleancreateDirectoryOrExist(String dirPath)创建或返回目录是否已经存在对于频繁创建目录的行为做了包装处理,如果目录不存在 则创建目录,并加入到局内缓存,避免多次查找文件对象 仅需关心文件转储或者其他业务内容,无需关心目录是否已经创建 注意:一般来说,结果都会返回true 如果不是true,行为差异出现在 File. final static StringgetResourceFileAsString(String filename)final static URLgetResourceFile(String filename)Gets the files in the run directory. final static URLgetClassesFile(String filename)final static StringgetRuntimePath(Boolean returnDir)Gets the run path of the JAR. final static StringgetRuntimePath(Class<?> clazz)Gets the run path of the javaClass. final static StringgetThreadPath()final static URLgetJarResource(String filename)Get the resource files in the JAR package. final static InputStreamgetJarResourceAsStream(String filename)Get the resource files in the JAR package. final static FilegetResourceFileAsFile(String filename)final static StringgetFileContent(File file)Convert a file to a string. final static StringgetFileSuffix(String fileName)获取文件路径文件名后缀 final static StringgetFileSuffix(File file)final static BooleanisImg(String suffix)检测是否为图片 其实应该用文件头检查,但是目前没空,先用文件名检查 final static Booleanexists(File file)final static FilefindFileInPossibleLocation(String path)Find file in possible location 寻找文件可能存在的位置 -
-
Method Detail
-
createDirectoryOrExist
final static Boolean createDirectoryOrExist(String dirPath)
创建或返回目录是否已经存在
对于频繁创建目录的行为做了包装处理,如果目录不存在 则创建目录,并加入到局内缓存,避免多次查找文件对象 仅需关心文件转储或者其他业务内容,无需关心目录是否已经创建 注意:一般来说,结果都会返回true 如果不是true,行为差异出现在 File.mkdirs()中
- Returns:
目录已存在或者目录已经生成
-
getResourceFileAsString
final static String getResourceFileAsString(String filename)
-
getResourceFile
final static URL getResourceFile(String filename)
Gets the files in the run directory.
-
getClassesFile
final static URL getClassesFile(String filename)
-
getRuntimePath
final static String getRuntimePath(Boolean returnDir)
Gets the run path of the JAR.
-
getRuntimePath
final static String getRuntimePath(Class<?> clazz)
Gets the run path of the javaClass.
-
getThreadPath
final static String getThreadPath()
-
getJarResource
final static URL getJarResource(String filename)
Get the resource files in the JAR package.
-
getJarResourceAsStream
final static InputStream getJarResourceAsStream(String filename)
Get the resource files in the JAR package.
-
getResourceFileAsFile
final static File getResourceFileAsFile(String filename)
-
getFileContent
final static String getFileContent(File file)
Convert a file to a string.
-
getFileSuffix
final static String getFileSuffix(String fileName)
获取文件路径文件名后缀
-
getFileSuffix
final static String getFileSuffix(File file)
-
findFileInPossibleLocation
final static File findFileInPossibleLocation(String path)
Find file in possible location 寻找文件可能存在的位置
- Parameters:
path- 文件路径- Returns:
文件
-
-
-
-