java ͸Ã÷ͼƬ
¹ØÓÚJavaÉú³É±³¾°Í¸Ã÷µÄpngͼƬ
×î½üÓõ½Java¶¯Ì¬Éú³É±³¾°Í¸Ã÷µÄͼƬ¹¦ÄÜ£¬´ÓgifºÍpngÖÐÑ¡ÔñÁËpng¸ñʽ£¬¸öÖÐÔµÓɾͲ»ËµÁË£¬ÓÚÊǶ¯ÊÖµ½ÍøÉÏËÑË÷ÓÐÓõĴúÂë¡£ÏÖ°ÑËÑË÷½á¹û×ܽáÈçÏ£º
1. Éú³ÉpngͼƬ
int width = 400;
int height = 300;
// ´´½¨BufferedImage¶ÔÏó
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// »ñÈ¡Graphics2D
Graphics2D g2d = image.createGraphics();
// »Í¼
g2d.setColor(new Color(255,0,0));
g2d.setStroke(new BasicStroke(1));
g2d.draw
//ÊͷŶÔÏó
g2d.dispose();
// ±£´æÎļþ
ImageIO.write(image, "png", new File("c:/test.png"));
int width = 400;
int height = 300;
// ´´½¨BufferedImage¶ÔÏó
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// »ñÈ¡Graphics2D
Graphics2D g2d = image.createGraphics();
// »Í¼
g2d.setColor(new Color(255,0,0));
g2d.setStroke(new BasicStroke(1));
g2d.draw
//ÊͷŶÔÏó
g2d.dispose();
// ±£´æÎļþ
ImageIO.write(image, "png", new File("c:/test.png"));
ÕâÖ»ÊÇ»æÖÆÍ¼ÐεĴúÂ룬Æä±³¾°ÊǺÚÉ«µÄ£¬ÈçºÎ²ÅÄܱ³¾°Í¸Ã÷ÄØ£¿¼ÌÐøËÑË÷£¬Ã»Óеõ½½á¹û£¬²»¹ýËѳöÒÔÏ´úÂ룬ËüÖ»ÊǰÑ×Ô¼º»æÖƵÄͼÐÎÉèÖÃΪ͸Ã÷»ò°ë͸Ã÷£¬±³¾°²¢²»Í¸Ã÷£¬ÈçÏ£º
2. »æÖưë͸Ã÷ͼÐÎ
int width = 400;
int height = 300;
// ´´½¨BufferedImage¶ÔÏó
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// »ñÈ¡Graphics2D
Graphics2D g2d = image.createGraphics();
// ÉèÖÃ͸Ã÷¶È
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 1.0fΪ͸Ã÷¶È £¬Öµ´Ó0-1.0£¬ÒÀ´Î±äµÃ²»Í¸Ã÷
// »Í¼
Ïà¹ØÎĵµ£º
ÕâÀïÖ»ÄÜ´ÓÏÔʾÊý¾ÝµÄjspÒ³ÃæÉϵ¼³öµ±Ç°Ò³ÃæµÄÊý¾Ý£¬ÕâЩÊý¾Ý¿ÉÒÔ´ÓÊý¾Ý¿â¶Á³ö£¬ÏÔʾµ½jspÒ³Ãæ£¬È»ºó¼ÓÒ»¶Î»°¾Í¿É°Ñµ±Ç°Ò³ÃæÊý¾Ý±£´æµ½excelÀïÃæ!
Èç´Óºǫ́¹ýÀ´Êý¾ÝÏÔʾµ½ showUser.jsp
È»ºó¼ÓÁ´½Óµ½ showExcel.jsp¾Í¿ÉÒÔÁË£¬ÔÚÕâ¸öÒ³ÃæÖ»¶àÁ˼¸ÐÐ×Ö£¬ÆäËûµÄ¶¼²»»áÏÔʾ°üÀ¨Ò³Ã棡µ«Õâ¸öÒ³ÃæÉϵÄÊý¾Ý¸úshowUser.js ......
JAVA·´Éä»úÖÆ
JAVA·´Éä»úÖÆÊÇÔÚÔËÐÐ״̬ÖУ¬¶ÔÓÚÈÎÒâÒ»¸öÀ࣬¶¼Äܹ»ÖªµÀÕâ¸öÀàµÄËùÓÐÊôÐԺͷ½·¨£»¶ÔÓÚÈÎÒâÒ»¸ö¶ÔÏ󣬶¼Äܹ»µ÷ÓÃËüµÄÈÎÒâÒ»¸ö·½·¨£»ÕâÖÖ¶¯Ì¬»ñÈ¡µÄÐÅÏ¢ÒÔ¼°¶¯Ì¬µ÷ÓöÔÏóµÄ·½·¨µÄ¹¦ÄܳÆÎªjavaÓïÑԵķ´Éä»úÖÆ¡£
Java·´Éä»úÖÆÖ÷ÒªÌṩÁËÒÔϹ¦ÄÜ£º ÔÚÔËÐÐʱÅжÏÈÎÒâÒ»¸ö¶ÔÏóËùÊô ......
Ò»¡¢Í¨¹ýHttpClient(apache commons-httpclient)·½Ê½£¬»ñÐíÍøÒ³ÄÚÈÝ£¬²¢½âÎö³öÐèÒªµÄ¶«Î÷¡£
ÕâÖÖ·½·¨Ïà¶Ô±È½Ï¼òµ¥£¬ÒòΪcommons-httpclientÒѾ×öÁ˺ܺõķâ×°£¬¼òµ¥µÄ´úÂëÈçÏ£º
// ¹¹ÔìHttpClientµÄʵÀý
HttpClient httpClient = new HttpClient();
HttpClientParams clientPar ......
String str = "ÖÐ";
String str1 = new String(str.getBytes("gbk"), "ISO8859-1");
String str2 = new String(str1.getBytes("ISO8859-1"), "gbk");
System.out.println(str2); //Êä³ö"ÖÐ" ......
¿ÉÄÜÓкܶàѧϰJavaµÄÅóÓÑ»¹²»ÖªµÀJavaµÄÔËÐÐÔÀí¡¢JavaÐéÄâ»úÊÇÔõô¹¤×÷µÄ£¬±¾ÎĽ«ÎªÄãÏêϸ½²½â(JVM)Java ÐéÄâ»ú¡£
¡¡¡¡ÔÚJavaÖÐÒýÈëÁËÐéÄâ»úµÄ¸ÅÄ¼´ÔÚ»úÆ÷ºÍ±àÒë³ÌÐòÖ®¼ä¼ÓÈëÁËÒ»²ã³éÏóµÄÐéÄâµÄ»úÆ÷¡£Õą̂ÐéÄâµÄ»úÆ÷ÔÚÈÎºÎÆ½Ì¨É϶¼Ìṩ¸ø±àÒë³ÌÐòÒ»¸öµÄ¹²Í¬µÄ½Ó¿Ú¡£±àÒë³ ......