dromara / hutool Goto Github PK
View Code? Open in Web Editor NEW🍬A set of tools that keep Java sweet.
Home Page: https://hutool.cn/
License: Other
🍬A set of tools that keep Java sweet.
Home Page: https://hutool.cn/
License: Other
如果没有的话可不可以只能加关键信息加密功能
在使用hutool 3.2.3版本ExcelUtil.read07BySax读取excel时候发现读取日期返回的字符串有问题,格式变成了yyyy-MM-ddHH:mm:ss,而不是yyy-MM-dd HH:mm:ss格式, 部分空单元格未显示为,如图。
excel见附件。
testExcel.xlsx
谢谢。
CollectionUtil这个类在使用过程中是经常使用的,尤其是newHashMap、newHashSet、newArrayList这几个方法; 在调用这几个方法的时候,需要写"CollectionUtil"这么长的类名,很不方便,如果像guava那样,只用写"Maps.xxx"这样是很方便的. 另外能不能加创建Map时有类似guava的ImmutableMap.of(key, value)方法直接创建键值对
RT,在使用DataSource的时候,用
sqlRunner.find( Entity.create("表名").set("id", "> 30"));
获取的List 里面tableName=null, fieldNames=null 其他的字段有值.
请问一下大神,我想用spring 管理数据源,生成DsFactory Bean, 然后要用的时候就要注入DsFactory获取sqlrunner就可以用啦,这样是否可行呢
见标题
使用SqlRunner.FindAll转型失败
List<T> findAll(Entity where, Class<T> beanClass)
转型没报错,但是使用时会提示ClassCaseExcepiton 错误.
When I try and follow the windows instructions in the readme I get the following error:
cl.exe /nologo /O2 /EHsc /D "_CRT_SECURE_NO_DEPRECATE" /D "USEOMP" /openmp tsne.obj sptree.obj -Fewindows\bh_tsne.exe
libcpmt.lib(xthrow.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in tsne.obj
libucrt.lib(hypot.obj) : error LNK2005: hypot already defined in tsne.obj
windows\bh_tsne.exe : fatal error LNK1169: one or more multiply defined symbols found
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe"' : return code '0x2'
Stop.
I'm not sure how I can edit the tsne.obj file to adjust this, any advice?
IntMap, LongMap, 求商, 求余可以使用位操作优化, LongMap中add, remove中似乎是存在问题[强转int, 丢失数据], 缺少对于range的校验
BitSetBloomFilter 扩展一点可以增加自定义的HashFunction, 以及使用一些预定义的HashFunction, init的时候 提供类似于LineTokenizer接口, 对于一行数据应该做校验, 提供类似于LineFilter
filter包里面的单个hashFunc的BloomFilter实现似乎是没有太大的意义, hash冲突的可能性太大了
BitMapBloomFilter.add方法对于结果的处理有问题, 还有一些写法层面上的可以改进的地方
为什么不使用cache 包实现的 lru 缓存,而是用了 simple 实现
com.xiaoleilu.hutool.poi.excel.ExcelReader的229行左右,sheet.getRow()会返回null会导致错误,希望可以看看是不是我使用的问题
感觉 L1433、L1435 逻辑有问题
只是个人的建议。。
如题
Is there a way to input sparse data? I suspect this is not a straight-forward thing to do, because of the lack of a standard way to store sparse matrices in a text file, i.e. python probably does it different than matlab (did not check though).
如果能够支持其他 http 方法会更好,另外没有 postString 功能,这个很常用
io工具包里面的FiltUtil等为啥都定义成final类型的class。本来想继承一下,再写一些自己的方法,发现是final类型的。
FileUtil 788行
会错误的把文件也判断成文件夹
FileUtil.internalCopyDir 方法中对于原文件是否为文件夹的的判断有问题
if(src.isDirectory())
src
应该改为srcFile
if(srcFile.isDirectory())
用于SQL语句的快速创建
如题,虽然通过HttpRequest可以实现代理,但还是觉得很麻烦
调用 ImageUtil.pressImage() 方法后,执行delete无法删除,报如下错误
2017-09-11 16:40:16
[ERROR]-[Thread: qtp632249781-29]-[com.jfinal.core.ActionHandler.handle()]: /edu/teacher/getLearningCardImage
com.jfinal.render.RenderException: com.xiaoleilu.hutool.io.IORuntimeException: FileSystemException: E:\IdeaCode\AgentAPI\src\main\webapp\temp\fb1facb023054ef99c8a58c0c9733763.png: 另一个程序正在使用此文件,进程无法访问。
在这里qrcodeFile和destFile都是作为临时文件用的,用过之后要删除,但是发现删除不掉
现在JSONUtil默认是过滤掉属性值为null的属性,要是可以增加一个可配置的选项就好了。类似fastjson的SerializerFeature
因为前段时间受病毒影响,一个外部FTP服务器从被动模式修改为主动模式(个人感觉没有用,FTP又用不到445),导致自己负责的项目完全死掉了,后来将项目中的连接模式设为了主动才修复。所以建议新增一个构造方法或者set方法设置连接模式为主动模式
ftpClient.enterLocalActiveMode();//连接模式设为主动模式
ftpClient.setActivePortRange(int,int);//客户端使用端口范围
程序中出现[WARN] Can not find [logging.properties], use [%JRE_HOME%/lib/logging.properties] as default!这行警告,请问这个问题如何解决?
在使用ZIPUtil的时候用了unzip 默认解压方法,系统运行报错 MALFORMED 后来觉得是压缩包里面有中文文件名,然后改成指定编码 ZipUtil.unzip(filePath, Charset.forName("gbk"))
,还是不能正常解压缩,系统运行报错MALFORMED 。
版本号V3.2.2
错误代码如下:
java.lang.IllegalArgumentException: MALFORMED at java.util.zip.ZipCoder.toString(ZipCoder.java:58) at java.util.zip.ZipFile.getZipEntry(ZipFile.java:531)
希望该方法里面设置default header时 header(Header.ACCEPT_ENCODING, "gzip", true);
这个不要默认设置,不然输出来的数据还需要手工用gzip去解压.
header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded", true);
好像只有post,patch,put 时才有用吧
另外302跳转的支持最好也加上,用一个参数来控制是否跳转
增加Sql Server Dialect
增加Mail支持
增加C3P0数据源支持
code sinppets in "Aspcet. invoke"
try {
result = ClassUtil.invoke(target, method, args);
}catch (InvocationTargetException e) {
afterException(args, method, args, e.getTargetException());
}catch (Exception e) {
throw e;//其它异常属于代理的异常,直接抛出
}
afterException 的第一个参数, 根据上下文, 应该是target嘛, 这里写错了
关于这个afterExecption的使用, 为什么要这样约定呀
json数据如下:
{
"statusCode": 200,
"message": "OK",
"skip": 0,
"limit": 20,
"total": 30,
"data": [
{
"Price": {
"ADT": [
[
{
"BookingCode": [
"N",
"N"
]
}
]
]
}
}
]
}
建立相应的bean
public class ADT {
private List<String> BookingCode;
public void setBookingCode(List<String> BookingCode) {
this.BookingCode = BookingCode;
}
public List<String> getBookingCode() {
return BookingCode;
}
}
public class Data {
private Price Price;
public void setPrice(Price Price) {
this.Price = Price;
}
public Price getPrice() {
return Price;
}
}
public class JsonRootBean {
private int statusCode;
private String message;
private int skip;
private int limit;
private int total;
private List<Data> data;
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}
public int getStatusCode() {
return statusCode;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void setSkip(int skip) {
this.skip = skip;
}
public int getSkip() {
return skip;
}
public void setLimit(int limit) {
this.limit = limit;
}
public int getLimit() {
return limit;
}
public void setTotal(int total) {
this.total = total;
}
public int getTotal() {
return total;
}
public void setData(List<Data> data) {
this.data = data;
}
public List<Data> getData() {
return data;
}
}
public class Price {
private List<List<ADT>> ADT;
public void setADT(List<List<ADT>> ADT) {
this.ADT = ADT;
}
public List<List<ADT>> getADT() {
return ADT;
}
}
test:
public static void main(String[] args) {
String json = "{"statusCode":200,"message":"OK","skip":0,"limit":20,"total":30,"data":[{"Price":{"ADT":[[{"BookingCode":["N","N"]}]]}}]}";
JsonRootBean objJsonRootBean = JSONUtil.toBean(json, JsonRootBean.class);
ADT sObject = objJsonRootBean.getData().get(0).getPrice().getADT().get(0).get(0);
System.out.println(sObject.getBookingCode());
}
error:
Exception in thread "main" java.lang.ClassCastException: com.xiaoleilu.hutool.json.JSONObject cannot be cast to sss.ADT
at sss.test.main(test.java:12)
https://github.com/looly/hutool/pulls
麻烦看看我提交修改的代码能不能合并到你的版本中来,谢谢
这里有 typo 吧 秋天是 autumn 而不是 ANTUMN 是 u 不是 n
import static com.xiaoleilu.hutool.util.RuntimeUtil.exec;
final List<String> exec = exec("which java");
异常
Exception in thread "main" com.xiaoleilu.hutool.io.IORuntimeException: IOException: Cannot run program "which java": error=2, No such file or directory
at com.xiaoleilu.hutool.util.RuntimeUtil.exec(RuntimeUtil.java:32)
at nio.files.SymbolicLinksDemo.main(SymbolicLinksDemo.java:15)
Caused by: java.io.IOException: Cannot run program "which java": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at com.xiaoleilu.hutool.util.RuntimeUtil.exec(RuntimeUtil.java:30)
... 1 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 2 more
发送email的封装
hutool-system包下的方法都不是静态的,每次使用都需要new一个对象,感觉使用起来不太方便,能不能改成静态方法, 这样感觉用起来比较顺手,谢谢
File f = new File("G:\\1231\\6666\\tttt\\出错.txt");
try {
System.out.println("file size= " + f.length());
System.out.println(FileTypeUtil.getType(f));
} catch (IOException e) {
e.printStackTrace();
}
//===>
#file size= 0
#java.lang.ArrayIndexOutOfBoundsException
CronUtil.remove方法不是静态的,想用这个方法都用不了额
增加图形验证码和二维码支持
public static String getContentTypeByRequestBody(String body) {
String contentType = null;
if(StrUtil.isNotBlank(body)) {
char firstChar = body.charAt(0);
switch (firstChar) {
case '{':
//JSON请求体
contentType = "application/json";
break;
case '<':
//XML请求体
contentType = "application/xml";
break;
default:
break;
}
}
return contentType;
}
上述代码中,是通过case '{':
是通过判断body是否以‘{’开头来判定是否是json参数请求,忽略了json数组的情况,如:[{},{},{},{}]
, Java-Controller代码:
@RequestMapping(value = "testSaveBatch.do", method = RequestMethod.POST)
@ResponseBody
public ServerResponse<String> testSaveBatch(@RequestBody List<SaleDetailVo> vos, String userAccount) throws Exception {
}
。故而,此种情况也应该判定为json参数请求。您这边看下,我描述是否有问题,如果描述正确的话,还请修正下。谢谢。
今天使用了FileTypeUtil类判断文件类型后,执行删除文件操作,执行失败,原因是文件被占用,发现占用的是java.exe。本来怀疑是自己代码有问题,后来尝试将FileTypeUtil的使用去掉,文件正常删除。
初步判定是FileTypeUtil读取文件后未关闭。
FileTypeUtil文件中,此代码
public static String getType(File file) throws IORuntimeException {
return getType(IoUtil.toStream(file));
}
没有对输入流关闭导致
尝试将代码改成
public static String getType(File file) throws IORuntimeException {
FileInputStream inputStream = IoUtil.toStream(file);
String type = getType(inputStream);
IoUtil.close(inputStream);
return type;
}
后执行,判断后文件不再提示被占用,能够正常删除。
再次感谢分享这么方便的工具。
代码实例
//随机生成密钥
byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
AES aes = new AES(Mode.CBC, Padding.NoPadding, key);
aes.setIv(new IvParameterSpec("0102030405060708".getBytes()));
//加密
byte[] encrypt = aes.encrypt(content);
报错如下:
com.xiaoleilu.hutool.crypto.CryptoException: InvalidKeyException: Wrong algorithm: AES or Rijndael required
at com.xiaoleilu.hutool.crypto.symmetric.SymmetricCrypto.encrypt(SymmetricCrypto.java:132)
at com.xiaoleilu.hutool.crypto.symmetric.SymmetricCrypto.encrypt(SymmetricCrypto.java:174)
at com.xu.spider4j.encrypt.SymmetricTest.aesTest3(SymmetricTest.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.security.InvalidKeyException: Wrong algorithm: AES or Rijndael required
at com.sun.crypto.provider.AESCrypt.init(AESCrypt.java:83)
at com.sun.crypto.provider.CipherBlockChaining.init(CipherBlockChaining.java:93)
at com.sun.crypto.provider.CipherCore.init(CipherCore.java:591)
at com.sun.crypto.provider.AESCipher.engineInit(AESCipher.java:346)
at javax.crypto.Cipher.implInit(Cipher.java:806)
at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
at javax.crypto.Cipher.init(Cipher.java:1396)
at javax.crypto.Cipher.init(Cipher.java:1327)
at com.xiaoleilu.hutool.crypto.symmetric.SymmetricCrypto.encrypt(SymmetricCrypto.java:128)
... 24 more
如:一条数据,包含创建时间、有效期长短,过期判断。
public static void main(String[] args) {
Date startDate = DateUtil.parseDateTime("2017-09-04 11:52:00");
Date now = DateUtil.parseDateTime("2017-09-04 12:51:00");
System.out.println(isExpired(startDate, now, 1, DateField.HOUR));
}
static boolean isExpired(Date startDate, Date nowDate, Integer timeLength, DateField dateField){
Date endDate = DateUtil.offsiteDate(startDate, dateField, timeLength);
return endDate.before(nowDate);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.