Merge pull request #1620 from cal101/erefactor/v5-dev-project/1/jdt/jdt-RemoveAllTrailingWhitespaceCleanUp-2

[cleanup] erefactor/EclipseJdt - Remove trailing whitespace - All lines
This commit is contained in:
Golden Looly 2021-06-06 07:56:10 +08:00 committed by GitHub
commit a65d77eb63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 144 additions and 144 deletions

View File

@ -14,7 +14,7 @@ import java.util.List;
* 持有一个文件在内存中积累一定量的数据后统一追加到文件<br> * 持有一个文件在内存中积累一定量的数据后统一追加到文件<br>
* 此类只有在写入文件时打开文件并在写入结束后关闭之因此此类不需要关闭<br> * 此类只有在写入文件时打开文件并在写入结束后关闭之因此此类不需要关闭<br>
* 在调用append方法后会缓存于内存只有超过容量后才会一次性写入文件因此内存中随时有剩余未写入文件的内容在最后必须调用flush方法将剩余内容刷入文件 * 在调用append方法后会缓存于内存只有超过容量后才会一次性写入文件因此内存中随时有剩余未写入文件的内容在最后必须调用flush方法将剩余内容刷入文件
* *
* @author looly * @author looly
* @since 3.1.2 * @since 3.1.2
*/ */
@ -27,10 +27,10 @@ public class FileAppender implements Serializable{
/** 追加内容是否为新行 */ /** 追加内容是否为新行 */
private final boolean isNewLineMode; private final boolean isNewLineMode;
private final List<String> list = new ArrayList<>(100); private final List<String> list = new ArrayList<>(100);
/** /**
* 构造 * 构造
* *
* @param destFile 目标文件 * @param destFile 目标文件
* @param capacity 当行数积累多少条时刷入到文件 * @param capacity 当行数积累多少条时刷入到文件
* @param isNewLineMode 追加内容是否为新行 * @param isNewLineMode 追加内容是否为新行
@ -41,7 +41,7 @@ public class FileAppender implements Serializable{
/** /**
* 构造 * 构造
* *
* @param destFile 目标文件 * @param destFile 目标文件
* @param charset 编码 * @param charset 编码
* @param capacity 当行数积累多少条时刷入到文件 * @param capacity 当行数积累多少条时刷入到文件
@ -55,7 +55,7 @@ public class FileAppender implements Serializable{
/** /**
* 追加 * 追加
* *
* @param line * @param line
* @return this * @return this
*/ */
@ -69,7 +69,7 @@ public class FileAppender implements Serializable{
/** /**
* 刷入到文件 * 刷入到文件
* *
* @return this * @return this
*/ */
public FileAppender flush() { public FileAppender flush() {

View File

@ -23,13 +23,13 @@ import java.util.ArrayList;
* 3目录复制到目录 * 3目录复制到目录
* 4目录下的文件和目录复制到另一个目录 * 4目录下的文件和目录复制到另一个目录
* </pre> * </pre>
* *
* @author Looly * @author Looly
* @since 3.0.9 * @since 3.0.9
*/ */
public class FileCopier extends SrcToDestCopier<File, FileCopier>{ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 是否覆盖目标文件 */ /** 是否覆盖目标文件 */
private boolean isOverride; private boolean isOverride;
/** 是否拷贝所有属性 */ /** 是否拷贝所有属性 */
@ -38,7 +38,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
private boolean isCopyContentIfDir; private boolean isCopyContentIfDir;
/** 当拷贝来源是目录时是否只拷贝文件而忽略子目录 */ /** 当拷贝来源是目录时是否只拷贝文件而忽略子目录 */
private boolean isOnlyCopyFile; private boolean isOnlyCopyFile;
//-------------------------------------------------------------------------------------------------------- static method start //-------------------------------------------------------------------------------------------------------- static method start
/** /**
* 新建一个文件复制器 * 新建一个文件复制器
@ -49,7 +49,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
public static FileCopier create(String srcPath, String destPath) { public static FileCopier create(String srcPath, String destPath) {
return new FileCopier(FileUtil.file(srcPath), FileUtil.file(destPath)); return new FileCopier(FileUtil.file(srcPath), FileUtil.file(destPath));
} }
/** /**
* 新建一个文件复制器 * 新建一个文件复制器
* @param src 源文件 * @param src 源文件
@ -60,7 +60,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
return new FileCopier(src, dest); return new FileCopier(src, dest);
} }
//-------------------------------------------------------------------------------------------------------- static method end //-------------------------------------------------------------------------------------------------------- static method end
//-------------------------------------------------------------------------------------------------------- Constructor start //-------------------------------------------------------------------------------------------------------- Constructor start
/** /**
* 构造 * 构造
@ -72,7 +72,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
this.dest = dest; this.dest = dest;
} }
//-------------------------------------------------------------------------------------------------------- Constructor end //-------------------------------------------------------------------------------------------------------- Constructor end
//-------------------------------------------------------------------------------------------------------- Getters and Setters start //-------------------------------------------------------------------------------------------------------- Getters and Setters start
/** /**
* 是否覆盖目标文件 * 是否覆盖目标文件
@ -115,7 +115,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
public boolean isCopyContentIfDir() { public boolean isCopyContentIfDir() {
return isCopyContentIfDir; return isCopyContentIfDir;
} }
/** /**
* 当拷贝来源是目录时是否只拷贝目录下的内容 * 当拷贝来源是目录时是否只拷贝目录下的内容
* @param isCopyContentIfDir 是否只拷贝目录下的内容 * @param isCopyContentIfDir 是否只拷贝目录下的内容
@ -125,10 +125,10 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
this.isCopyContentIfDir = isCopyContentIfDir; this.isCopyContentIfDir = isCopyContentIfDir;
return this; return this;
} }
/** /**
* 当拷贝来源是目录时是否只拷贝文件而忽略子目录 * 当拷贝来源是目录时是否只拷贝文件而忽略子目录
* *
* @return 当拷贝来源是目录时是否只拷贝文件而忽略子目录 * @return 当拷贝来源是目录时是否只拷贝文件而忽略子目录
* @since 4.1.5 * @since 4.1.5
*/ */
@ -138,7 +138,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
/** /**
* 设置当拷贝来源是目录时是否只拷贝文件而忽略子目录 * 设置当拷贝来源是目录时是否只拷贝文件而忽略子目录
* *
* @param isOnlyCopyFile 当拷贝来源是目录时是否只拷贝文件而忽略子目录 * @param isOnlyCopyFile 当拷贝来源是目录时是否只拷贝文件而忽略子目录
* @return this * @return this
* @since 4.1.5 * @since 4.1.5
@ -161,7 +161,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
* 6源为目录目标为文件抛出IO异常 * 6源为目录目标为文件抛出IO异常
* 7源路径和目标路径相同时抛出IO异常 * 7源路径和目标路径相同时抛出IO异常
* </pre> * </pre>
* *
* @return 拷贝后目标的文件或目录 * @return 拷贝后目标的文件或目录
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
*/ */
@ -187,7 +187,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
if(FileUtil.isSub(src, dest)) { if(FileUtil.isSub(src, dest)) {
throw new IORuntimeException("Dest is a sub directory of src !"); throw new IORuntimeException("Dest is a sub directory of src !");
} }
final File subTarget = isCopyContentIfDir ? dest : FileUtil.mkdir(FileUtil.file(dest, src.getName())); final File subTarget = isCopyContentIfDir ? dest : FileUtil.mkdir(FileUtil.file(dest, src.getName()));
internalCopyDirContent(src, subTarget); internalCopyDirContent(src, subTarget);
} else {// 复制文件 } else {// 复制文件
@ -200,7 +200,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
/** /**
* 拷贝目录内容只用于内部不做任何安全检查<br> * 拷贝目录内容只用于内部不做任何安全检查<br>
* 拷贝内容的意思为源目录下的所有文件和目录拷贝到另一个目录下而不拷贝源目录本身 * 拷贝内容的意思为源目录下的所有文件和目录拷贝到另一个目录下而不拷贝源目录本身
* *
* @param src 源目录 * @param src 源目录
* @param dest 目标目录 * @param dest 目标目录
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
@ -218,7 +218,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
} else if (false == dest.isDirectory()) { } else if (false == dest.isDirectory()) {
throw new IORuntimeException(StrUtil.format("Src [{}] is a directory but dest [{}] is a file!", src.getPath(), dest.getPath())); throw new IORuntimeException(StrUtil.format("Src [{}] is a directory but dest [{}] is a file!", src.getPath(), dest.getPath()));
} }
final String[] files = src.list(); final String[] files = src.list();
if(ArrayUtil.isNotEmpty(files)){ if(ArrayUtil.isNotEmpty(files)){
File srcFile; File srcFile;
@ -243,7 +243,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
* 1如果目标是一个不存在的路径则目标以文件对待自动创建父级目录比如/dest/aaa如果aaa不存在则aaa被当作文件名 * 1如果目标是一个不存在的路径则目标以文件对待自动创建父级目录比如/dest/aaa如果aaa不存在则aaa被当作文件名
* 2如果目标是一个已存在的目录则文件拷贝到此目录下文件名与原文件名一致 * 2如果目标是一个已存在的目录则文件拷贝到此目录下文件名与原文件名一致
* </pre> * </pre>
* *
* @param src 源文件必须为文件 * @param src 源文件必须为文件
* @param dest 目标文件如果非覆盖模式必须为目录 * @param dest 目标文件如果非覆盖模式必须为目录
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
@ -253,14 +253,14 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
//被过滤的文件跳过 //被过滤的文件跳过
return; return;
} }
// 如果已经存在目标文件切为不覆盖模式跳过之 // 如果已经存在目标文件切为不覆盖模式跳过之
if (dest.exists()) { if (dest.exists()) {
if(dest.isDirectory()) { if(dest.isDirectory()) {
//目标为目录目录下创建同名文件 //目标为目录目录下创建同名文件
dest = new File(dest, src.getName()); dest = new File(dest, src.getName());
} }
if(dest.exists() && false == isOverride) { if(dest.exists() && false == isOverride) {
//非覆盖模式跳过 //非覆盖模式跳过
return; return;
@ -270,7 +270,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
//noinspection ResultOfMethodCallIgnored //noinspection ResultOfMethodCallIgnored
dest.getParentFile().mkdirs(); dest.getParentFile().mkdirs();
} }
final ArrayList<CopyOption> optionList = new ArrayList<>(2); final ArrayList<CopyOption> optionList = new ArrayList<>(2);
if(isOverride) { if(isOverride) {
optionList.add(StandardCopyOption.REPLACE_EXISTING); optionList.add(StandardCopyOption.REPLACE_EXISTING);
@ -278,7 +278,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
if(isCopyAttributes) { if(isCopyAttributes) {
optionList.add(StandardCopyOption.COPY_ATTRIBUTES); optionList.add(StandardCopyOption.COPY_ATTRIBUTES);
} }
try { try {
Files.copy(src.toPath(), dest.toPath(), optionList.toArray(new CopyOption[0])); Files.copy(src.toPath(), dest.toPath(), optionList.toArray(new CopyOption[0]));
} catch (IOException e) { } catch (IOException e) {

View File

@ -2,7 +2,7 @@ package cn.hutool.core.io.file;
/** /**
* 文件读写模式常用于RandomAccessFile * 文件读写模式常用于RandomAccessFile
* *
* @author looly * @author looly
* @since 4.5.2 * @since 4.5.2
*/ */

View File

@ -20,13 +20,13 @@ import java.util.List;
/** /**
* 文件读取器 * 文件读取器
* *
* @author Looly * @author Looly
* *
*/ */
public class FileReader extends FileWrapper { public class FileReader extends FileWrapper {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 创建 FileReader * 创建 FileReader
* @param file 文件 * @param file 文件
@ -36,7 +36,7 @@ public class FileReader extends FileWrapper {
public static FileReader create(File file, Charset charset){ public static FileReader create(File file, Charset charset){
return new FileReader(file, charset); return new FileReader(file, charset);
} }
/** /**
* 创建 FileReader, 编码{@link FileWrapper#DEFAULT_CHARSET} * 创建 FileReader, 编码{@link FileWrapper#DEFAULT_CHARSET}
* @param file 文件 * @param file 文件
@ -45,7 +45,7 @@ public class FileReader extends FileWrapper {
public static FileReader create(File file){ public static FileReader create(File file){
return new FileReader(file); return new FileReader(file);
} }
// ------------------------------------------------------- Constructor start // ------------------------------------------------------- Constructor start
/** /**
* 构造 * 构造
@ -106,7 +106,7 @@ public class FileReader extends FileWrapper {
/** /**
* 读取文件所有数据<br> * 读取文件所有数据<br>
* 文件的长度不能超过 {@link Integer#MAX_VALUE} * 文件的长度不能超过 {@link Integer#MAX_VALUE}
* *
* @return 字节码 * @return 字节码
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
*/ */
@ -136,7 +136,7 @@ public class FileReader extends FileWrapper {
/** /**
* 读取文件内容 * 读取文件内容
* *
* @return 内容 * @return 内容
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
*/ */
@ -146,7 +146,7 @@ public class FileReader extends FileWrapper {
/** /**
* 从文件中读取每一行数据 * 从文件中读取每一行数据
* *
* @param <T> 集合类型 * @param <T> 集合类型
* @param collection 集合 * @param collection 集合
* @return 文件中的每行内容的集合 * @return 文件中的每行内容的集合
@ -171,10 +171,10 @@ public class FileReader extends FileWrapper {
IoUtil.close(reader); IoUtil.close(reader);
} }
} }
/** /**
* 按照行处理文件内容 * 按照行处理文件内容
* *
* @param lineHandler 行处理器 * @param lineHandler 行处理器
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
* @since 3.0.9 * @since 3.0.9
@ -188,10 +188,10 @@ public class FileReader extends FileWrapper {
IoUtil.close(reader); IoUtil.close(reader);
} }
} }
/** /**
* 从文件中读取每一行数据 * 从文件中读取每一行数据
* *
* @return 文件中的每行内容的集合 * @return 文件中的每行内容的集合
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
*/ */
@ -201,7 +201,7 @@ public class FileReader extends FileWrapper {
/** /**
* 按照给定的readerHandler读取文件中的数据 * 按照给定的readerHandler读取文件中的数据
* *
* @param <T> 读取的结果对象类型 * @param <T> 读取的结果对象类型
* @param readerHandler Reader处理类 * @param readerHandler Reader处理类
* @return 从文件中read出的数据 * @return 从文件中read出的数据
@ -223,7 +223,7 @@ public class FileReader extends FileWrapper {
/** /**
* 获得一个文件读取器 * 获得一个文件读取器
* *
* @return BufferedReader对象 * @return BufferedReader对象
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
*/ */
@ -233,7 +233,7 @@ public class FileReader extends FileWrapper {
/** /**
* 获得输入流 * 获得输入流
* *
* @return 输入流 * @return 输入流
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
*/ */
@ -255,10 +255,10 @@ public class FileReader extends FileWrapper {
public long writeToStream(OutputStream out) throws IORuntimeException { public long writeToStream(OutputStream out) throws IORuntimeException {
return writeToStream(out, false); return writeToStream(out, false);
} }
/** /**
* 将文件写入流中 * 将文件写入流中
* *
* @param out * @param out
* @param isCloseOut 是否关闭输出流 * @param isCloseOut 是否关闭输出流
* @return 写出的流byte数 * @return 写出的流byte数
@ -280,7 +280,7 @@ public class FileReader extends FileWrapper {
// -------------------------------------------------------------------------- Interface start // -------------------------------------------------------------------------- Interface start
/** /**
* Reader处理接口 * Reader处理接口
* *
* @author Luxiaolei * @author Luxiaolei
* *
* @param <T> Reader处理返回结果类型 * @param <T> Reader处理返回结果类型
@ -289,10 +289,10 @@ public class FileReader extends FileWrapper {
T handle(BufferedReader reader) throws IOException; T handle(BufferedReader reader) throws IOException;
} }
// -------------------------------------------------------------------------- Interface end // -------------------------------------------------------------------------- Interface end
/** /**
* 检查文件 * 检查文件
* *
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
*/ */
private void checkFile() throws IORuntimeException { private void checkFile() throws IORuntimeException {

View File

@ -10,16 +10,16 @@ import cn.hutool.core.util.CharsetUtil;
/** /**
* 文件包装器扩展文件对象 * 文件包装器扩展文件对象
* *
* @author Looly * @author Looly
* *
*/ */
public class FileWrapper implements Serializable{ public class FileWrapper implements Serializable{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected File file; protected File file;
protected Charset charset; protected Charset charset;
/** 默认编码UTF-8 */ /** 默认编码UTF-8 */
public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;

View File

@ -27,7 +27,7 @@ import java.util.Map.Entry;
*/ */
public class FileWriter extends FileWrapper{ public class FileWriter extends FileWrapper{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 创建 FileWriter * 创建 FileWriter
* @param file 文件 * @param file 文件
@ -37,7 +37,7 @@ public class FileWriter extends FileWrapper{
public static FileWriter create(File file, Charset charset){ public static FileWriter create(File file, Charset charset){
return new FileWriter(file, charset); return new FileWriter(file, charset);
} }
/** /**
* 创建 FileWriter, 编码{@link FileWrapper#DEFAULT_CHARSET} * 创建 FileWriter, 编码{@link FileWrapper#DEFAULT_CHARSET}
* @param file 文件 * @param file 文件
@ -46,7 +46,7 @@ public class FileWriter extends FileWrapper{
public static FileWriter create(File file){ public static FileWriter create(File file){
return new FileWriter(file); return new FileWriter(file);
} }
// ------------------------------------------------------- Constructor start // ------------------------------------------------------- Constructor start
/** /**
* 构造 * 构造
@ -103,10 +103,10 @@ public class FileWriter extends FileWrapper{
this(filePath, DEFAULT_CHARSET); this(filePath, DEFAULT_CHARSET);
} }
// ------------------------------------------------------- Constructor end // ------------------------------------------------------- Constructor end
/** /**
* 将String写入文件 * 将String写入文件
* *
* @param content 写入的内容 * @param content 写入的内容
* @param isAppend 是否追加 * @param isAppend 是否追加
* @return 目标文件 * @return 目标文件
@ -125,10 +125,10 @@ public class FileWriter extends FileWrapper{
} }
return file; return file;
} }
/** /**
* 将String写入文件覆盖模式 * 将String写入文件覆盖模式
* *
* @param content 写入的内容 * @param content 写入的内容
* @return 目标文件 * @return 目标文件
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
@ -139,7 +139,7 @@ public class FileWriter extends FileWrapper{
/** /**
* 将String写入文件追加模式 * 将String写入文件追加模式
* *
* @param content 写入的内容 * @param content 写入的内容
* @return 写入的文件 * @return 写入的文件
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
@ -150,7 +150,7 @@ public class FileWriter extends FileWrapper{
/** /**
* 将列表写入文件覆盖模式 * 将列表写入文件覆盖模式
* *
* @param <T> 集合元素类型 * @param <T> 集合元素类型
* @param list 列表 * @param list 列表
* @return 目标文件 * @return 目标文件
@ -162,7 +162,7 @@ public class FileWriter extends FileWrapper{
/** /**
* 将列表写入文件追加模式 * 将列表写入文件追加模式
* *
* @param <T> 集合元素类型 * @param <T> 集合元素类型
* @param list 列表 * @param list 列表
* @return 目标文件 * @return 目标文件
@ -174,7 +174,7 @@ public class FileWriter extends FileWrapper{
/** /**
* 将列表写入文件 * 将列表写入文件
* *
* @param <T> 集合元素类型 * @param <T> 集合元素类型
* @param list 列表 * @param list 列表
* @param isAppend 是否追加 * @param isAppend 是否追加
@ -184,10 +184,10 @@ public class FileWriter extends FileWrapper{
public <T> File writeLines(Collection<T> list, boolean isAppend) throws IORuntimeException { public <T> File writeLines(Collection<T> list, boolean isAppend) throws IORuntimeException {
return writeLines(list, null, isAppend); return writeLines(list, null, isAppend);
} }
/** /**
* 将列表写入文件 * 将列表写入文件
* *
* @param <T> 集合元素类型 * @param <T> 集合元素类型
* @param list 列表 * @param list 列表
* @param lineSeparator 换行符枚举WindowsMac或Linux换行符 * @param lineSeparator 换行符枚举WindowsMac或Linux换行符
@ -208,10 +208,10 @@ public class FileWriter extends FileWrapper{
} }
return this.file; return this.file;
} }
/** /**
* 将Map写入文件每个键值对为一行一行中键与值之间使用kvSeparator分隔 * 将Map写入文件每个键值对为一行一行中键与值之间使用kvSeparator分隔
* *
* @param map Map * @param map Map
* @param kvSeparator 键和值之间的分隔符如果传入null使用默认分隔符" = " * @param kvSeparator 键和值之间的分隔符如果传入null使用默认分隔符" = "
* @param isAppend 是否追加 * @param isAppend 是否追加
@ -222,10 +222,10 @@ public class FileWriter extends FileWrapper{
public File writeMap(Map<?, ?> map, String kvSeparator, boolean isAppend) throws IORuntimeException { public File writeMap(Map<?, ?> map, String kvSeparator, boolean isAppend) throws IORuntimeException {
return writeMap(map, null, kvSeparator, isAppend); return writeMap(map, null, kvSeparator, isAppend);
} }
/** /**
* 将Map写入文件每个键值对为一行一行中键与值之间使用kvSeparator分隔 * 将Map写入文件每个键值对为一行一行中键与值之间使用kvSeparator分隔
* *
* @param map Map * @param map Map
* @param lineSeparator 换行符枚举WindowsMac或Linux换行符 * @param lineSeparator 换行符枚举WindowsMac或Linux换行符
* @param kvSeparator 键和值之间的分隔符如果传入null使用默认分隔符" = " * @param kvSeparator 键和值之间的分隔符如果传入null使用默认分隔符" = "
@ -249,10 +249,10 @@ public class FileWriter extends FileWrapper{
} }
return this.file; return this.file;
} }
/** /**
* 写入数据到文件 * 写入数据到文件
* *
* @param data 数据 * @param data 数据
* @param off 数据开始位置 * @param off 数据开始位置
* @param len 数据长度 * @param len 数据长度
@ -262,10 +262,10 @@ public class FileWriter extends FileWrapper{
public File write(byte[] data, int off, int len) throws IORuntimeException { public File write(byte[] data, int off, int len) throws IORuntimeException {
return write(data, off, len, false); return write(data, off, len, false);
} }
/** /**
* 追加数据到文件 * 追加数据到文件
* *
* @param data 数据 * @param data 数据
* @param off 数据开始位置 * @param off 数据开始位置
* @param len 数据长度 * @param len 数据长度
@ -278,7 +278,7 @@ public class FileWriter extends FileWrapper{
/** /**
* 写入数据到文件 * 写入数据到文件
* *
* @param data 数据 * @param data 数据
* @param off 数据开始位置 * @param off 数据开始位置
* @param len 数据长度 * @param len 数据长度
@ -314,7 +314,7 @@ public class FileWriter extends FileWrapper{
/** /**
* 将流的内容写入文件 * 将流的内容写入文件
* *
* @param in 输入流不关闭 * @param in 输入流不关闭
* @param isCloseIn 是否关闭输入流 * @param isCloseIn 是否关闭输入流
* @return dest * @return dest
@ -339,7 +339,7 @@ public class FileWriter extends FileWrapper{
/** /**
* 获得一个输出流对象 * 获得一个输出流对象
* *
* @return 输出流对象 * @return 输出流对象
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
*/ */
@ -353,7 +353,7 @@ public class FileWriter extends FileWrapper{
/** /**
* 获得一个带缓存的写入对象 * 获得一个带缓存的写入对象
* *
* @param isAppend 是否追加 * @param isAppend 是否追加
* @return BufferedReader对象 * @return BufferedReader对象
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
@ -368,7 +368,7 @@ public class FileWriter extends FileWrapper{
/** /**
* 获得一个打印写入对象可以有print * 获得一个打印写入对象可以有print
* *
* @param isAppend 是否追加 * @param isAppend 是否追加
* @return 打印对象 * @return 打印对象
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
@ -376,10 +376,10 @@ public class FileWriter extends FileWrapper{
public PrintWriter getPrintWriter(boolean isAppend) throws IORuntimeException { public PrintWriter getPrintWriter(boolean isAppend) throws IORuntimeException {
return new PrintWriter(getWriter(isAppend)); return new PrintWriter(getWriter(isAppend));
} }
/** /**
* 检查文件 * 检查文件
* *
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
*/ */
private void checkFile() throws IORuntimeException { private void checkFile() throws IORuntimeException {
@ -388,7 +388,7 @@ public class FileWriter extends FileWrapper{
throw new IORuntimeException("File [{}] is not a file !", this.file.getAbsoluteFile()); throw new IORuntimeException("File [{}] is not a file !", this.file.getAbsoluteFile());
} }
} }
/** /**
* 打印新行 * 打印新行
* @param writer Writer * @param writer Writer

View File

@ -13,7 +13,7 @@ import java.nio.file.WatchEvent;
/** /**
* 行处理的Watcher实现 * 行处理的Watcher实现
* *
* @author looly * @author looly
* @since 4.5.2 * @since 4.5.2
*/ */
@ -25,7 +25,7 @@ public class LineReadWatcher extends SimpleWatcher implements Runnable {
/** /**
* 构造 * 构造
* *
* @param randomAccessFile {@link RandomAccessFile} * @param randomAccessFile {@link RandomAccessFile}
* @param charset 编码 * @param charset 编码
* @param lineHandler 行处理器{@link LineHandler}实现 * @param lineHandler 行处理器{@link LineHandler}实现

View File

@ -8,7 +8,7 @@ package cn.hutool.core.io.file;
* Linux系统换行符"\n" * Linux系统换行符"\n"
* Windows系统换行符"\r\n" * Windows系统换行符"\r\n"
* </pre> * </pre>
* *
* @see #MAC * @see #MAC
* @see #LINUX * @see #LINUX
* @see #WINDOWS * @see #WINDOWS
@ -19,7 +19,7 @@ public enum LineSeparator {
/** Mac系统换行符"\r" */ /** Mac系统换行符"\r" */
MAC("\r"), MAC("\r"),
/** Linux系统换行符"\n" */ /** Linux系统换行符"\n" */
LINUX("\n"), LINUX("\n"),
/** Windows系统换行符"\r\n" */ /** Windows系统换行符"\r\n" */
WINDOWS("\r\n"); WINDOWS("\r\n");

View File

@ -1,6 +1,6 @@
/** /**
* 对文件读写的封装包括文件拷贝文件读取文件写出行处理等 * 对文件读写的封装包括文件拷贝文件读取文件写出行处理等
* *
* @author looly * @author looly
* *
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* FileVisitor功能性实现包括递归删除拷贝等 * FileVisitor功能性实现包括递归删除拷贝等
* *
* @author looly * @author looly
* *
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* IO相关封装和工具类包括Inputstream和OutputStream实现类工具包括流工具IoUtil文件工具FileUtil和Buffer工具BufferUtil * IO相关封装和工具类包括Inputstream和OutputStream实现类工具包括流工具IoUtil文件工具FileUtil和Buffer工具BufferUtil
* *
* @author looly * @author looly
* *
*/ */

View File

@ -12,7 +12,7 @@ import java.nio.charset.Charset;
/** /**
* 基于byte[]的资源获取器<br> * 基于byte[]的资源获取器<br>
* 注意此对象中getUrl方法始终返回null * 注意此对象中getUrl方法始终返回null
* *
* @author looly * @author looly
* @since 4.0.9 * @since 4.0.9
*/ */
@ -24,16 +24,16 @@ public class BytesResource implements Resource, Serializable {
/** /**
* 构造 * 构造
* *
* @param bytes 字节数组 * @param bytes 字节数组
*/ */
public BytesResource(byte[] bytes) { public BytesResource(byte[] bytes) {
this(bytes, null); this(bytes, null);
} }
/** /**
* 构造 * 构造
* *
* @param bytes 字节数组 * @param bytes 字节数组
* @param name 资源名称 * @param name 资源名称
*/ */
@ -41,7 +41,7 @@ public class BytesResource implements Resource, Serializable {
this.bytes = bytes; this.bytes = bytes;
this.name = name; this.name = name;
} }
@Override @Override
public String getName() { public String getName() {
return this.name; return this.name;

View File

@ -14,7 +14,7 @@ import java.nio.charset.Charset;
/** /**
* {@link CharSequence}资源字符串做为资源 * {@link CharSequence}资源字符串做为资源
* *
* @author looly * @author looly
* @since 5.5.2 * @since 5.5.2
*/ */

View File

@ -13,7 +13,7 @@ import cn.hutool.core.util.URLUtil;
* ClassPath单一资源访问类<br> * ClassPath单一资源访问类<br>
* 传入路径path必须为相对路径如果传入绝对路径Linux路径会去掉开头的/而Windows路径会直接报错<br> * 传入路径path必须为相对路径如果传入绝对路径Linux路径会去掉开头的/而Windows路径会直接报错<br>
* 传入的path所指向的资源必须存在否则报错 * 传入的path所指向的资源必须存在否则报错
* *
* @author Looly * @author Looly
* *
*/ */
@ -27,7 +27,7 @@ public class ClassPathResource extends UrlResource {
// -------------------------------------------------------------------------------------- Constructor start // -------------------------------------------------------------------------------------- Constructor start
/** /**
* 构造 * 构造
* *
* @param path 相对于ClassPath的路径 * @param path 相对于ClassPath的路径
*/ */
public ClassPathResource(String path) { public ClassPathResource(String path) {
@ -36,7 +36,7 @@ public class ClassPathResource extends UrlResource {
/** /**
* 构造 * 构造
* *
* @param path 相对于ClassPath的路径 * @param path 相对于ClassPath的路径
* @param classLoader {@link ClassLoader} * @param classLoader {@link ClassLoader}
*/ */
@ -46,7 +46,7 @@ public class ClassPathResource extends UrlResource {
/** /**
* 构造 * 构造
* *
* @param path 相对于给定Class的路径 * @param path 相对于给定Class的路径
* @param clazz {@link Class} 用于定位路径 * @param clazz {@link Class} 用于定位路径
*/ */
@ -56,7 +56,7 @@ public class ClassPathResource extends UrlResource {
/** /**
* 构造 * 构造
* *
* @param pathBaseClassLoader 相对路径 * @param pathBaseClassLoader 相对路径
* @param classLoader {@link ClassLoader} * @param classLoader {@link ClassLoader}
* @param clazz {@link Class} 用于定位路径 * @param clazz {@link Class} 用于定位路径
@ -64,11 +64,11 @@ public class ClassPathResource extends UrlResource {
public ClassPathResource(String pathBaseClassLoader, ClassLoader classLoader, Class<?> clazz) { public ClassPathResource(String pathBaseClassLoader, ClassLoader classLoader, Class<?> clazz) {
super((URL) null); super((URL) null);
Assert.notNull(pathBaseClassLoader, "Path must not be null"); Assert.notNull(pathBaseClassLoader, "Path must not be null");
final String path = normalizePath(pathBaseClassLoader); final String path = normalizePath(pathBaseClassLoader);
this.path = path; this.path = path;
this.name = StrUtil.isBlank(path) ? null : FileUtil.getName(path); this.name = StrUtil.isBlank(path) ? null : FileUtil.getName(path);
this.classLoader = ObjectUtil.defaultIfNull(classLoader, ClassUtil.getClassLoader()); this.classLoader = ObjectUtil.defaultIfNull(classLoader, ClassUtil.getClassLoader());
this.clazz = clazz; this.clazz = clazz;
initUrl(); initUrl();
@ -77,7 +77,7 @@ public class ClassPathResource extends UrlResource {
/** /**
* 获得Path * 获得Path
* *
* @return path * @return path
*/ */
public final String getPath() { public final String getPath() {
@ -87,7 +87,7 @@ public class ClassPathResource extends UrlResource {
/** /**
* 获得绝对路径Path<br> * 获得绝对路径Path<br>
* 对于不存在的资源返回拼接后的绝对路径 * 对于不存在的资源返回拼接后的绝对路径
* *
* @return 绝对路径path * @return 绝对路径path
*/ */
public final String getAbsolutePath() { public final String getAbsolutePath() {
@ -100,7 +100,7 @@ public class ClassPathResource extends UrlResource {
/** /**
* 获得 {@link ClassLoader} * 获得 {@link ClassLoader}
* *
* @return {@link ClassLoader} * @return {@link ClassLoader}
*/ */
public final ClassLoader getClassLoader() { public final ClassLoader getClassLoader() {
@ -130,7 +130,7 @@ public class ClassPathResource extends UrlResource {
/** /**
* 标准化Path格式 * 标准化Path格式
* *
* @param path Path * @param path Path
* @return 标准化后的path * @return 标准化后的path
*/ */

View File

@ -11,7 +11,7 @@ import java.nio.file.Path;
/** /**
* 文件资源访问对象支持{@link Path} {@link File} 访问 * 文件资源访问对象支持{@link Path} {@link File} 访问
* *
* @author looly * @author looly
*/ */
public class FileResource implements Resource, Serializable { public class FileResource implements Resource, Serializable {
@ -22,7 +22,7 @@ public class FileResource implements Resource, Serializable {
// ----------------------------------------------------------------------- Constructor start // ----------------------------------------------------------------------- Constructor start
/** /**
* 构造 * 构造
* *
* @param path 文件 * @param path 文件
* @since 4.4.1 * @since 4.4.1
*/ */
@ -32,7 +32,7 @@ public class FileResource implements Resource, Serializable {
/** /**
* 构造 * 构造
* *
* @param file 文件 * @param file 文件
*/ */
public FileResource(File file) { public FileResource(File file) {
@ -41,7 +41,7 @@ public class FileResource implements Resource, Serializable {
/** /**
* 构造 * 构造
* *
* @param file 文件 * @param file 文件
* @param fileName 文件名如果为null获取文件本身的文件名 * @param fileName 文件名如果为null获取文件本身的文件名
*/ */
@ -51,7 +51,7 @@ public class FileResource implements Resource, Serializable {
/** /**
* 构造 * 构造
* *
* @param path 文件绝对路径或相对ClassPath路径但是这个路径不能指向一个jar包中的文件 * @param path 文件绝对路径或相对ClassPath路径但是这个路径不能指向一个jar包中的文件
*/ */
public FileResource(String path) { public FileResource(String path) {

View File

@ -7,7 +7,7 @@ import java.net.URL;
/** /**
* 基于{@link InputStream}的资源获取器<br> * 基于{@link InputStream}的资源获取器<br>
* 注意此对象中getUrl方法始终返回null * 注意此对象中getUrl方法始终返回null
* *
* @author looly * @author looly
* @since 4.0.9 * @since 4.0.9
*/ */
@ -19,16 +19,16 @@ public class InputStreamResource implements Resource, Serializable {
/** /**
* 构造 * 构造
* *
* @param in {@link InputStream} * @param in {@link InputStream}
*/ */
public InputStreamResource(InputStream in) { public InputStreamResource(InputStream in) {
this(in, null); this(in, null);
} }
/** /**
* 构造 * 构造
* *
* @param in {@link InputStream} * @param in {@link InputStream}
* @param name 资源名称 * @param name 资源名称
*/ */
@ -36,7 +36,7 @@ public class InputStreamResource implements Resource, Serializable {
this.in = in; this.in = in;
this.name = name; this.name = name;
} }
@Override @Override
public String getName() { public String getName() {
return this.name; return this.name;

View File

@ -6,34 +6,34 @@ import java.util.Collection;
/** /**
* 多文件组合资源<br> * 多文件组合资源<br>
* 此资源为一个利用游标自循环资源只有调用{@link #next()} 方法才会获取下一个资源使用完毕后调用{@link #reset()}方法重置游标 * 此资源为一个利用游标自循环资源只有调用{@link #next()} 方法才会获取下一个资源使用完毕后调用{@link #reset()}方法重置游标
* *
* @author looly * @author looly
* *
*/ */
public class MultiFileResource extends MultiResource{ public class MultiFileResource extends MultiResource{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 构造 * 构造
* *
* @param files 文件资源列表 * @param files 文件资源列表
*/ */
public MultiFileResource(Collection<File> files) { public MultiFileResource(Collection<File> files) {
add(files); add(files);
} }
/** /**
* 构造 * 构造
* *
* @param files 文件资源列表 * @param files 文件资源列表
*/ */
public MultiFileResource(File... files) { public MultiFileResource(File... files) {
add(files); add(files);
} }
/** /**
* 增加文件资源 * 增加文件资源
* *
* @param files 文件资源 * @param files 文件资源
* @return this * @return this
*/ */
@ -43,10 +43,10 @@ public class MultiFileResource extends MultiResource{
} }
return this; return this;
} }
/** /**
* 增加文件资源 * 增加文件资源
* *
* @param files 文件资源 * @param files 文件资源
* @return this * @return this
*/ */
@ -56,7 +56,7 @@ public class MultiFileResource extends MultiResource{
} }
return this; return this;
} }
@Override @Override
public MultiFileResource add(Resource resource) { public MultiFileResource add(Resource resource) {
return (MultiFileResource)super.add(resource); return (MultiFileResource)super.add(resource);

View File

@ -16,7 +16,7 @@ import java.util.List;
/** /**
* 多资源组合资源<br> * 多资源组合资源<br>
* 此资源为一个利用游标自循环资源只有调用{@link #next()} 方法才会获取下一个资源使用完毕后调用{@link #reset()}方法重置游标 * 此资源为一个利用游标自循环资源只有调用{@link #next()} 方法才会获取下一个资源使用完毕后调用{@link #reset()}方法重置游标
* *
* @author looly * @author looly
* @since 4.1.0 * @since 4.1.0
*/ */
@ -25,10 +25,10 @@ public class MultiResource implements Resource, Iterable<Resource>, Iterator<Res
private final List<Resource> resources; private final List<Resource> resources;
private int cursor; private int cursor;
/** /**
* 构造 * 构造
* *
* @param resources 资源数组 * @param resources 资源数组
*/ */
public MultiResource(Resource... resources) { public MultiResource(Resource... resources) {
@ -37,7 +37,7 @@ public class MultiResource implements Resource, Iterable<Resource>, Iterator<Res
/** /**
* 构造 * 构造
* *
* @param resources 资源列表 * @param resources 资源列表
*/ */
public MultiResource(Collection<Resource> resources) { public MultiResource(Collection<Resource> resources) {
@ -113,7 +113,7 @@ public class MultiResource implements Resource, Iterable<Resource>, Iterator<Res
public synchronized void reset() { public synchronized void reset() {
this.cursor = 0; this.cursor = 0;
} }
/** /**
* 增加资源 * 增加资源
* @param resource 资源 * @param resource 资源

View File

@ -6,7 +6,7 @@ import cn.hutool.core.util.StrUtil;
/** /**
* 资源文件或资源不存在异常 * 资源文件或资源不存在异常
* *
* @author xiaoleilu * @author xiaoleilu
* @since 4.0.2 * @since 4.0.2
*/ */
@ -35,7 +35,7 @@ public class NoResourceException extends IORuntimeException {
/** /**
* 导致这个异常的异常是否是指定类型的异常 * 导致这个异常的异常是否是指定类型的异常
* *
* @param clazz 异常类 * @param clazz 异常类
* @return 是否为指定类型异常 * @return 是否为指定类型异常
*/ */

View File

@ -19,7 +19,7 @@ import java.util.List;
/** /**
* Resource资源工具类 * Resource资源工具类
* *
* @author Looly * @author Looly
* *
*/ */
@ -27,7 +27,7 @@ public class ResourceUtil {
/** /**
* 读取Classpath下的资源为字符串使用UTF-8编码 * 读取Classpath下的资源为字符串使用UTF-8编码
* *
* @param resource 资源路径使用相对ClassPath的路径 * @param resource 资源路径使用相对ClassPath的路径
* @return 资源内容 * @return 资源内容
* @since 3.1.1 * @since 3.1.1
@ -38,7 +38,7 @@ public class ResourceUtil {
/** /**
* 读取Classpath下的资源为字符串 * 读取Classpath下的资源为字符串
* *
* @param resource 可以是绝对路径也可以是相对路径相对ClassPath * @param resource 可以是绝对路径也可以是相对路径相对ClassPath
* @param charset 编码 * @param charset 编码
* @return 资源内容 * @return 资源内容
@ -47,10 +47,10 @@ public class ResourceUtil {
public static String readStr(String resource, Charset charset) { public static String readStr(String resource, Charset charset) {
return getResourceObj(resource).readStr(charset); return getResourceObj(resource).readStr(charset);
} }
/** /**
* 读取Classpath下的资源为byte[] * 读取Classpath下的资源为byte[]
* *
* @param resource 可以是绝对路径也可以是相对路径相对ClassPath * @param resource 可以是绝对路径也可以是相对路径相对ClassPath
* @return 资源内容 * @return 资源内容
* @since 4.5.19 * @since 4.5.19
@ -61,7 +61,7 @@ public class ResourceUtil {
/** /**
* 从ClassPath资源中获取{@link InputStream} * 从ClassPath资源中获取{@link InputStream}
* *
* @param resource ClassPath资源 * @param resource ClassPath资源
* @return {@link InputStream} * @return {@link InputStream}
* @throws NoResourceException 资源不存在异常 * @throws NoResourceException 资源不存在异常
@ -73,7 +73,7 @@ public class ResourceUtil {
/** /**
* 从ClassPath资源中获取{@link InputStream}当资源不存在时返回null * 从ClassPath资源中获取{@link InputStream}当资源不存在时返回null
* *
* @param resource ClassPath资源 * @param resource ClassPath资源
* @return {@link InputStream} * @return {@link InputStream}
* @since 4.0.3 * @since 4.0.3
@ -100,7 +100,7 @@ public class ResourceUtil {
/** /**
* 从ClassPath资源中获取{@link BufferedReader} * 从ClassPath资源中获取{@link BufferedReader}
* *
* @param resource ClassPath资源 * @param resource ClassPath资源
* @param charset 编码 * @param charset 编码
* @return {@link InputStream} * @return {@link InputStream}
@ -113,12 +113,12 @@ public class ResourceUtil {
/** /**
* 获得资源的URL<br> * 获得资源的URL<br>
* 路径用/分隔例如: * 路径用/分隔例如:
* *
* <pre> * <pre>
* config/a/db.config * config/a/db.config
* spring/xml/test.xml * spring/xml/test.xml
* </pre> * </pre>
* *
* @param resource 资源相对Classpath的路径 * @param resource 资源相对Classpath的路径
* @return 资源URL * @return 资源URL
*/ */
@ -129,12 +129,12 @@ public class ResourceUtil {
/** /**
* 获取指定路径下的资源列表<br> * 获取指定路径下的资源列表<br>
* 路径格式必须为目录格式,/分隔例如: * 路径格式必须为目录格式,/分隔例如:
* *
* <pre> * <pre>
* config/a * config/a
* spring/xml * spring/xml
* </pre> * </pre>
* *
* @param resource 资源路径 * @param resource 资源路径
* @return 资源列表 * @return 资源列表
*/ */
@ -151,12 +151,12 @@ public class ResourceUtil {
/** /**
* 获取指定路径下的资源Iterator<br> * 获取指定路径下的资源Iterator<br>
* 路径格式必须为目录格式,/分隔例如: * 路径格式必须为目录格式,/分隔例如:
* *
* <pre> * <pre>
* config/a * config/a
* spring/xml * spring/xml
* </pre> * </pre>
* *
* @param resource 资源路径 * @param resource 资源路径
* @return 资源列表 * @return 资源列表
* @since 4.1.5 * @since 4.1.5
@ -173,7 +173,7 @@ public class ResourceUtil {
/** /**
* 获得资源相对路径对应的URL * 获得资源相对路径对应的URL
* *
* @param resource 资源相对路径 * @param resource 资源相对路径
* @param baseClass 基准Class获得的相对路径相对于此Class所在路径如果为{@code null}则相对ClassPath * @param baseClass 基准Class获得的相对路径相对于此Class所在路径如果为{@code null}则相对ClassPath
* @return {@link URL} * @return {@link URL}
@ -185,7 +185,7 @@ public class ResourceUtil {
/** /**
* 获取{@link Resource} 资源对象<br> * 获取{@link Resource} 资源对象<br>
* 如果提供路径为绝对路径或路径以file:开头返回{@link FileResource}否则返回{@link ClassPathResource} * 如果提供路径为绝对路径或路径以file:开头返回{@link FileResource}否则返回{@link ClassPathResource}
* *
* @param path 路径可以是绝对路径也可以是相对路径相对ClassPath * @param path 路径可以是绝对路径也可以是相对路径相对ClassPath
* @return {@link Resource} 资源对象 * @return {@link Resource} 资源对象
* @since 3.2.1 * @since 3.2.1