public class UrlResource extends Object implements Resource
| Modifier and Type | Field and Description |
|---|---|
protected String |
name |
protected URL |
url |
| Constructor and Description |
|---|
UrlResource(URL url)
构造
|
UrlResource(URL url,
String name)
构造
|
| Modifier and Type | Method and Description |
|---|---|
File |
getFile()
获得File
|
String |
getName()
获取资源名,例如文件资源的资源名为文件名
|
BufferedReader |
getReader(Charset charset)
获得Reader
|
InputStream |
getStream()
获得
InputStream |
URL |
getUrl()
获得解析后的
URL |
byte[] |
readBytes()
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取
|
String |
readStr(Charset charset)
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取
|
String |
readUtf8Str()
读取资源内容,读取完毕后会关闭流
关闭流并不影响下一次读取
|
String |
toString()
返回路径
|
public UrlResource(URL url)
url - URLpublic InputStream getStream()
ResourceInputStreamgetStream in interface ResourceInputStreampublic BufferedReader getReader(Charset charset)
getReader in interface Resourcecharset - 编码BufferedReaderpublic String readStr(Charset charset) throws InstrumentException
ResourcereadStr in interface Resourcecharset - 编码InstrumentException - 包装IOExceptionpublic String readUtf8Str() throws InstrumentException
ResourcereadUtf8Str in interface ResourceInstrumentException - 包装IOExceptionpublic byte[] readBytes()
throws InstrumentException
ResourcereadBytes in interface ResourceInstrumentException - 包装IOExceptionCopyright © 2019. All rights reserved.