public class FileResource extends Object implements Resource
| Constructor and Description |
|---|
FileResource(File file)
构造,文件名使用文件本身的名字,带扩展名
|
FileResource(File file,
String fileName)
构造
|
FileResource(Path path)
构造,文件名使用文件本身的名字,带扩展名
|
FileResource(String path)
构造
|
| Modifier and Type | Method and Description |
|---|---|
File |
getFile()
获取文件
|
String |
getName()
获取资源名,例如文件资源的资源名为文件名
|
InputStream |
getStream()
获得
InputStream |
URL |
getUrl()
获得解析后的
URL |
String |
toString()
返回路径
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetReader, readBytes, readString, writeTopublic FileResource(Path path)
path - 文件public FileResource(File file)
file - 文件public FileResource(File file, String fileName)
file - 文件fileName - 文件名,如果为null获取文件本身的文件名public FileResource(String path)
path - 文件绝对路径或相对ClassPath路径,但是这个路径不能指向一个jar包中的文件public InputStream getStream()
ResourceInputStreamgetStream in interface ResourceInputStreampublic File getFile()
Copyright © 2022. All rights reserved.