Tag:java Verification Code console public
public class test2 {/** * Verification Code Learning * @param args * @throws ioexception */public static void main (String[] args) throws ioexception {char[] ch = "ABCDEFGHIGKLMNQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789". ToCharArray (); Random rand = new random ();int index = 0; string s = ""; for (int i=0;i<4;i++) {index = rand.nextint; s+= Character.tostring (Ch[index]);} System.out.println (s); System.out.println ("Please enter:"); byte[] b = new byte[1024];int n = system.in.read (b); String ss = new string (B, 0, n); SYSTEM.OUT.PRINTLN (ss); Ss = ss.touppercase (); S = s.touppercase ();ss = Ss.substring (0,&NBSP;4); SYSTEM.OUT.PRINTLN (ss), if (S.equals (ss)) {System.out.println ("Success");} Else{system.out.println ("Failed");}}}
public class Test3 {/** * generate picture * @param args * @throws ioexception */public static void Main (string[] args) throws Ioexce ption {bufferedimage image = new BufferedImage (+, BUFFEREDIMAGE.TYPE_INT_RGB); Graphics g = Image.getgraphics (); G.setcolor (new Color (254,255,80)); G.fillrect (0, 0, +); G.setcolor (color.red); G.setfont (New Font ("Arial", Font.Bold)), g.drawstring ("Hello World", +), g.drawimage (image, 0, 0, NULL); Mageio.write (image, "JPG", New File ("c://.."));}}
This article is from the "Riding monkey on the Tree" blog, please be sure to keep this source http://qihoushangshu.blog.51cto.com/7872138/1615000
Java Console simulation Verification code process