parent
a4e97e1190
commit
61001ab6b7
@ -0,0 +1,27 @@
|
||||
package com.zhehekeji.web.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class FileUtil {
|
||||
public static List<String> readLinesToList(String path) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(path))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
lines.add(line);
|
||||
}
|
||||
}catch (IOException e){
|
||||
log.info("读取数据失败");
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.zhehekeji.web.util;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class ToolUtil {
|
||||
public static boolean isEmpty(Object o) {
|
||||
if (o == null) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof String) {
|
||||
return ((String) o).isEmpty();
|
||||
}
|
||||
if (o instanceof Collection) {
|
||||
return ((Collection<?>) o).isEmpty();
|
||||
}
|
||||
if (o instanceof Map) {
|
||||
return ((Map<?, ?>) o).isEmpty();
|
||||
}
|
||||
if (o.getClass().isArray()) {
|
||||
return Array.getLength(o) == 0;
|
||||
}
|
||||
return "".equals(o.toString());
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(Object o) {
|
||||
return !isEmpty(o);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue