类 EncodedResource
- java.lang.Object
- org.springframework.core.io.support.EncodedResource
- 所有已实现的接口:
InputStreamSource
public class EncodedResource extends Object implements InputStreamSource
Holder that combines aResource
descriptor with a specific encoding orCharset
to be used for reading from the resource.Used as an argument for operations that support reading content with a specific encoding, typically via a
java.io.Reader
.- 从以下版本开始:
- 1.2.6
- 作者:
- Juergen Hoeller, Sam Brannen
- 另请参阅:
InputStreamSource.getInputStream()
,Reader
,Charset
构造器概要
构造器 构造器 说明 EncodedResource(Resource resource)
Create a newEncodedResource
for the givenResource
, not specifying an explicit encoding orCharset
.EncodedResource(Resource resource, String encoding)
Create a newEncodedResource
for the givenResource
, using the specifiedencoding
.EncodedResource(Resource resource, Charset charset)
Create a newEncodedResource
for the givenResource
, using the specifiedCharset
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 boolean
equals(Object other)
Charset
getCharset()
String
getEncoding()
Return the encoding to use for reading from the resource, ornull
if none specified.InputStream
getInputStream()
Reader
getReader()
Resource
getResource()
Return theResource
held by thisEncodedResource
.int
hashCode()
boolean
requiresReader()
Determine whether aReader
is required as opposed to anInputStream
, i.e. whether an encoding or aCharset
has been specified.String
toString()
构造器详细资料
EncodedResource
public EncodedResource(Resource resource)
Create a newEncodedResource
for the givenResource
, not specifying an explicit encoding orCharset
.- 参数:
resource
- theResource
to hold (nevernull
)
EncodedResource
public EncodedResource(Resource resource, String encoding)
Create a newEncodedResource
for the givenResource
, using the specifiedencoding
.- 参数:
resource
- theResource
to hold (nevernull
)encoding
- the encoding to use for reading from the resource
EncodedResource
public EncodedResource(Resource resource, Charset charset)
Create a newEncodedResource
for the givenResource
, using the specifiedCharset
.- 参数:
resource
- theResource
to hold (nevernull
)charset
- theCharset
to use for reading from the resource
方法详细资料
getResource
public final Resource getResource()
Return theResource
held by thisEncodedResource
.
getEncoding
public final String getEncoding()
Return the encoding to use for reading from the resource, ornull
if none specified.
getCharset
public final Charset getCharset()
requiresReader
public boolean requiresReader()
Determine whether aReader
is required as opposed to anInputStream
, i.e. whether an encoding or aCharset
has been specified.- 另请参阅:
getReader()
,getInputStream()
getReader
public Reader getReader() throws IOException
- 抛出:
IOException
- if opening the Reader failed- 另请参阅:
requiresReader()
,getInputStream()
getInputStream
public InputStream getInputStream() throws IOException
- 指定者:
getInputStream
在接口中InputStreamSource
- 返回:
- the input stream for the underlying resource (must not be
null
) - 抛出:
IOException
- if opening the InputStream failed- 另请参阅:
requiresReader()
,getReader()