1
0
mirror of synced 2026-05-21 01:36:32 +08:00

解决创建字体时 流未关闭 内存泄漏产生临时文件问题

This commit is contained in:
zlay0701
2021-07-16 16:53:21 +08:00
parent da3501451b
commit d427168287

View File

@@ -4,6 +4,7 @@ import java.awt.*;
import java.awt.geom.CubicCurve2D;
import java.awt.geom.QuadCurve2D;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Base64;
@@ -274,7 +275,7 @@ public abstract class Captcha extends Randoms {
}
public void setFont(int font, int style, float size) throws IOException, FontFormatException {
this.font = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("/" + FONT_NAMES[font])).deriveFont(style, size);
this.font = Font.createFont(Font.TRUETYPE_FONT, new File(getClass().getResource("/" + FONT_NAMES[font]).getFile())).deriveFont(style, size);
}
public int getLen() {