fix comment

This commit is contained in:
Looly
2020-04-07 11:26:21 +08:00
parent 91e9511738
commit b1e10cc763
3 changed files with 162 additions and 148 deletions

View File

@@ -1760,6 +1760,7 @@ public class CollUtil {
* @param <K> Map键类型 * @param <K> Map键类型
* @param <V> Map值类型 * @param <V> Map值类型
* @param values 数据列表 * @param values 数据列表
* @param map Map对象转换后的键值对加入此Map通过传入此对象自定义Map类型
* @param keyFunc 生成key的函数 * @param keyFunc 生成key的函数
* @return 生成的map * @return 生成的map
* @since 5.2.6 * @since 5.2.6
@@ -1778,6 +1779,7 @@ public class CollUtil {
* @param values 数据列表 * @param values 数据列表
* @param map Map对象转换后的键值对加入此Map通过传入此对象自定义Map类型 * @param map Map对象转换后的键值对加入此Map通过传入此对象自定义Map类型
* @param keyFunc 生成key的函数 * @param keyFunc 生成key的函数
* @param valueFunc 生成值的策略函数
* @return 生成的map * @return 生成的map
* @since 5.2.6 * @since 5.2.6
*/ */

View File

@@ -202,7 +202,7 @@ public class IterUtil {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <K, V> Map<K, V> fieldValueMap(Iterator<V> iter, String fieldName) { public static <K, V> Map<K, V> fieldValueMap(Iterator<V> iter, String fieldName) {
return toMap(iter, new HashMap<>(), (value)->(K)ReflectUtil.getFieldValue(value, fieldName)); return toMap(iter, new HashMap<>(), (value) -> (K) ReflectUtil.getFieldValue(value, fieldName));
} }
/** /**
@@ -236,8 +236,8 @@ public class IterUtil {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <K, V> Map<K, V> fieldValueAsMap(Iterator<?> iter, String fieldNameForKey, String fieldNameForValue) { public static <K, V> Map<K, V> fieldValueAsMap(Iterator<?> iter, String fieldNameForKey, String fieldNameForValue) {
return toMap(iter, new HashMap<>(), return toMap(iter, new HashMap<>(),
(value)->(K)ReflectUtil.getFieldValue(value, fieldNameForKey), (value) -> (K) ReflectUtil.getFieldValue(value, fieldNameForKey),
(value)->(V)ReflectUtil.getFieldValue(value, fieldNameForValue) (value) -> (V) ReflectUtil.getFieldValue(value, fieldNameForValue)
); );
} }
@@ -650,6 +650,7 @@ public class IterUtil {
* @param iterator 数据列表 * @param iterator 数据列表
* @param map Map对象转换后的键值对加入此Map通过传入此对象自定义Map类型 * @param map Map对象转换后的键值对加入此Map通过传入此对象自定义Map类型
* @param keyFunc 生成key的函数 * @param keyFunc 生成key的函数
* @param valueFunc 生成值的策略函数
* @return 生成的map * @return 生成的map
* @since 5.2.6 * @since 5.2.6
*/ */

View File

@@ -48,21 +48,29 @@ import java.util.zip.Checksum;
* IO工具类只是辅助流的读写并不负责关闭流。原因是流可能被多次读写读写关闭后容易造成问题。 * IO工具类只是辅助流的读写并不负责关闭流。原因是流可能被多次读写读写关闭后容易造成问题。
* *
* @author xiaoleilu * @author xiaoleilu
*
*/ */
public class IoUtil { public class IoUtil {
/** 默认缓存大小 8192*/ /**
* 默认缓存大小 8192
*/
public static final int DEFAULT_BUFFER_SIZE = 2 << 12; public static final int DEFAULT_BUFFER_SIZE = 2 << 12;
/** 默认中等缓存大小 16384*/ /**
* 默认中等缓存大小 16384
*/
public static final int DEFAULT_MIDDLE_BUFFER_SIZE = 2 << 13; public static final int DEFAULT_MIDDLE_BUFFER_SIZE = 2 << 13;
/** 默认大缓存大小 32768*/ /**
* 默认大缓存大小 32768
*/
public static final int DEFAULT_LARGE_BUFFER_SIZE = 2 << 14; public static final int DEFAULT_LARGE_BUFFER_SIZE = 2 << 14;
/** 数据流末尾 */ /**
* 数据流末尾
*/
public static final int EOF = -1; public static final int EOF = -1;
// -------------------------------------------------------------------------------------- Copy start // -------------------------------------------------------------------------------------- Copy start
/** /**
* 将Reader中的内容复制到Writer中 使用默认缓存大小拷贝后不关闭Reader * 将Reader中的内容复制到Writer中 使用默认缓存大小拷贝后不关闭Reader
* *
@@ -171,7 +179,7 @@ public class IoUtil {
} }
long size = 0; long size = 0;
try { try {
for (int readSize; (readSize = in.read(buffer)) != EOF;) { for (int readSize; (readSize = in.read(buffer)) != EOF; ) {
out.write(buffer, 0, readSize); out.write(buffer, 0, readSize);
size += readSize; size += readSize;
out.flush(); out.flush();
@@ -296,6 +304,7 @@ public class IoUtil {
// -------------------------------------------------------------------------------------- Copy end // -------------------------------------------------------------------------------------- Copy end
// -------------------------------------------------------------------------------------- getReader and getWriter start // -------------------------------------------------------------------------------------- getReader and getWriter start
/** /**
* 获得一个文件读取器默认使用UTF-8编码 * 获得一个文件读取器默认使用UTF-8编码
* *
@@ -412,6 +421,7 @@ public class IoUtil {
// -------------------------------------------------------------------------------------- getReader and getWriter end // -------------------------------------------------------------------------------------- getReader and getWriter end
// -------------------------------------------------------------------------------------- read start // -------------------------------------------------------------------------------------- read start
/** /**
* 从流中读取内容 * 从流中读取内容
* *
@@ -562,7 +572,7 @@ public class IoUtil {
public static byte[] readBytes(InputStream in, boolean isCloseStream) throws IORuntimeException { public static byte[] readBytes(InputStream in, boolean isCloseStream) throws IORuntimeException {
final FastByteArrayOutputStream out = new FastByteArrayOutputStream(); final FastByteArrayOutputStream out = new FastByteArrayOutputStream();
copy(in, out); copy(in, out);
if(isCloseStream){ if (isCloseStream) {
close(in); close(in);
} }
return out.toByteArray(); return out.toByteArray();
@@ -655,6 +665,7 @@ public class IoUtil {
* *
* @param <T> 读取对象的类型 * @param <T> 读取对象的类型
* @param in 输入流 * @param in 输入流
* @param clazz 读取对象类型
* @return 输出流 * @return 输出流
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
* @throws UtilException ClassNotFoundException包装 * @throws UtilException ClassNotFoundException包装