提交 ff85b825 编写于 作者: dong.an's avatar dong.an

图形验证码

上级 c36d1a90
流水线 #13103 已失败 于阶段
...@@ -34,13 +34,18 @@ public class CaptchaContext { ...@@ -34,13 +34,18 @@ public class CaptchaContext {
try { try {
InputStream fontStream = CaptchaGenerator.class.getClassLoader().getResourceAsStream("1.ttf"); InputStream fontStream = CaptchaGenerator.class.getClassLoader().getResourceAsStream("1.ttf");
fontDatas[0] = IOUtils.toByteArray(fontStream); fontDatas[0] = IOUtils.toByteArray(fontStream);
fontStream.close();
fontStream = CaptchaGenerator.class.getClassLoader().getResourceAsStream("2.ttf"); fontStream = CaptchaGenerator.class.getClassLoader().getResourceAsStream("2.ttf");
fontDatas[1] = IOUtils.toByteArray(fontStream); fontDatas[1] = IOUtils.toByteArray(fontStream);
fontStream.close();
fontStream = CaptchaGenerator.class.getClassLoader().getResourceAsStream("3.ttf"); fontStream = CaptchaGenerator.class.getClassLoader().getResourceAsStream("3.ttf");
fontDatas[2] = IOUtils.toByteArray(fontStream); fontDatas[2] = IOUtils.toByteArray(fontStream);
fontStream.close();
fontStream = CaptchaGenerator.class.getClassLoader().getResourceAsStream("4.ttf"); fontStream = CaptchaGenerator.class.getClassLoader().getResourceAsStream("4.ttf");
fontDatas[3] = IOUtils.toByteArray(fontStream); fontDatas[3] = IOUtils.toByteArray(fontStream);
fontStream.close();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
} }
} }
......
...@@ -24,7 +24,9 @@ public class CaptchaUtil { ...@@ -24,7 +24,9 @@ public class CaptchaUtil {
try { try {
InputStream imageStream = CaptchaUtil.class.getClassLoader().getResourceAsStream("1.png"); InputStream imageStream = CaptchaUtil.class.getClassLoader().getResourceAsStream("1.png");
imageData = IOUtils.toByteArray(imageStream); imageData = IOUtils.toByteArray(imageStream);
imageStream.close();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
} }
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册