testvalidcode.java
来自「创建网页页面验证的验证码」· Java 代码 · 共 31 行
JAVA
31 行
package mawen.test;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.imageio.stream.FileImageOutputStream;
import junit.framework.TestCase;
import mawen.util.ValidCode;
public class TestValidCode extends TestCase {
public static void testVC() throws FileNotFoundException, IOException {
File f = new File("E:\\downloads\\vc.jpg");
FileImageOutputStream fo = new FileImageOutputStream(f);
ValidCode vc= new ValidCode();
BufferedImage image = vc.getImage();
System.out.println(vc.getValidString());
ImageIO.write(image, "JPEG", fo);
fo.flush();
fo.close();
}
public static void testNullString() {
String str=null;
System.out.println(str);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?