Java Console simulation Verification code process

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.