public class ResourceManager extends Object
| 构造器和说明 |
|---|
ResourceManager(String rootPath) |
ResourceManager(String rootPath,
String workspace) |
ResourceManager(String rootPath,
String workspace,
ClassLoader classLoader) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
copyFile(String sourcePath,
String sourceFileName,
String targetPath,
String targetFileName)
Copy files
|
int |
countDir(String path)
Gets the number of folders in the path
|
int |
countFile(String path)
Gets the number of files in the path
|
boolean |
delete(String path)
Delete the directory
|
void |
deleteChild(String path)
Delete all subdirectories under directory
|
ClassLoader |
getClassLoader() |
String |
getRealPath(String path)
Get the real path
|
URL |
getResource(String path)
Access to resources
|
InputStream |
getResourceAsStream(String path)
Gets the data input stream
|
Set<String> |
getResourcePaths(String path)
Get all directories under path
|
String |
getRootPath()
Get the root path
|
String |
getWorkspace()
Get workspace
|
boolean |
mkdirs(String path)
Create file (can be created with parent file)
|
FileInputStream |
newFileInputStream(String sourcePath,
String sourceFileName)
newFileInputStream (note: close it after using)
|
FileOutputStream |
newFileOutputStream(String targetPath,
String targetFileName,
boolean append)
newFileOutputStream (note: close it after using)
|
String |
toString() |
void |
writeFile(byte[] data,
String targetPath,
String targetFileName)
Write files
|
void |
writeFile(byte[] data,
String targetPath,
String targetFileName,
boolean append)
Write files
|
void |
writeFile(InputStream inputStream,
String targetPath,
String targetFileName)
Write files
|
void |
writeFile(Iterator<ByteBuffer> dataIterator,
String targetPath,
String targetFileName)
Write files
|
public ResourceManager(String rootPath)
public ResourceManager(String rootPath, String workspace, ClassLoader classLoader)
public int countDir(String path)
path - pathpublic int countFile(String path)
path - pathpublic Set<String> getResourcePaths(String path)
path - pathpublic URL getResource(String path) throws MalformedURLException
path - Relative pathsMalformedURLException - MalformedURLExceptionpublic InputStream getResourceAsStream(String path)
path - pathpublic String getRealPath(String path)
path - Relative pathspublic ClassLoader getClassLoader()
public void writeFile(InputStream inputStream, String targetPath, String targetFileName) throws IOException
inputStream - datatargetPath - targetPathtargetFileName - targetFileNameIOException - IOExceptionpublic void writeFile(Iterator<ByteBuffer> dataIterator, String targetPath, String targetFileName) throws IOException
dataIterator - datatargetPath - targetPathtargetFileName - targetFileNameIOException - IOExceptionpublic void writeFile(byte[] data,
String targetPath,
String targetFileName)
throws IOException
data - datatargetPath - targetPathtargetFileName - targetFileNameIOException - IOExceptionpublic void writeFile(byte[] data,
String targetPath,
String targetFileName,
boolean append)
throws IOException
data - datatargetPath - targetPathtargetFileName - targetFileNameappend - Whether to concatenate old dataIOException - IOExceptionpublic FileOutputStream newFileOutputStream(String targetPath, String targetFileName, boolean append) throws IOException
targetPath - targetPathtargetFileName - targetFileNameappend - Whether to concatenate old dataIOException - IOExceptionpublic FileInputStream newFileInputStream(String sourcePath, String sourceFileName) throws FileNotFoundException
sourcePath - sourcePathsourceFileName - sourceFileNameFileNotFoundException - FileNotFoundExceptionpublic void copyFile(String sourcePath, String sourceFileName, String targetPath, String targetFileName) throws FileNotFoundException, IOException
sourcePath - sourcePathsourceFileName - sourceFileNametargetPath - targetPathtargetFileName - targetFileNameFileNotFoundException - FileNotFoundExceptionIOException - IOExceptionpublic boolean mkdirs(String path)
path - The file pathtrue if and only if the directory was created,
along with all necessary parent directories; false
otherwisepublic boolean delete(String path)
path - pathpublic void deleteChild(String path)
path - pathpublic String getWorkspace()
public String getRootPath()
Copyright © 2021. All rights reserved.