mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add YamlUtil
This commit is contained in:
34
hutool-db/src/test/java/cn/hutool/db/PicTransferTest.java
Normal file
34
hutool-db/src/test/java/cn/hutool/db/PicTransferTest.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package cn.hutool.db;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class PicTransferTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void findTest() throws SQLException {
|
||||
Db.use().find(
|
||||
ListUtil.of("NAME", "TYPE", "GROUP", "PIC"),
|
||||
Entity.create("PIC_INFO").set("TYPE", 1),
|
||||
rs -> {
|
||||
while(rs.next()){
|
||||
save(rs);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private static void save(ResultSet rs) throws SQLException{
|
||||
String destDir = "d:/test/pic";
|
||||
String path = StrUtil.format("{}/{}-{}.jpg", destDir, rs.getString("NAME"), rs.getString("GROUP"));
|
||||
FileUtil.writeFromStream(rs.getBlob("PIC").getBinaryStream(), path);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user