
com.star.io.resource.Resource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utils Show documentation
Show all versions of utils Show documentation
some utility class for java develop
The newest version!
package com.star.io.resource;
import com.star.exception.IORuntimeException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.Charset;
/**
* 资源接口定义
* 资源可以是文件、URL、ClassPath中的文件亦或者jar包中的文件
*
* @author looly
* @since 3.2.1
*/
public interface Resource {
/**
* 获得解析后的{@link URL}
*
* @return 解析后的{@link URL}
*/
URL getUrl();
/**
* 获得 {@link InputStream}
*
* @return {@link InputStream}
*/
InputStream getStream();
/**
* 获得Reader
*
* @param charset 编码
* @return {@link BufferedReader}
*/
BufferedReader getReader(Charset charset);
/**
* 读取资源内容,读取完毕后会关闭流
* 关闭流并不影响下一次读取
*
* @param charset 编码
* @return 读取资源内容
* @throws IORuntimeException 包装{@link IOException}
*/
String readStr(Charset charset) throws IORuntimeException;
/**
* 读取资源内容,读取完毕后会关闭流
* 关闭流并不影响下一次读取
*
* @return 读取资源内容
* @throws IORuntimeException 包装IOException
*/
String readUtf8Str() throws IORuntimeException;
/**
* 读取资源内容,读取完毕后会关闭流
* 关闭流并不影响下一次读取
*
* @return 读取资源内容
* @throws IORuntimeException 包装IOException
*/
byte[] readBytes() throws IORuntimeException;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy