ʹÓÃJava½øÐÐͼÏñ´¦Àí
¡¾Òý×Ô¼üÅÌÉϵÄÎèÕߵIJ©¿Í¡¿Í¼Ïñ±àÂëÊä³öµÄ·½·¨£¬Ìṩ±àÂë½ø¶È¼àÌý£¬ÉèÖñàÂëÖÊÁ¿µÄÖ§³Ö£¨Ìض¨¸ñʽ£¬ÀýÈçJPG£©¡£
Õâ¸ö·½·¨Ö§³ÖµÄ±àÂë¸ñʽÒÀÀµÔËÐл·¾³ÀïImageIOÒѾע²áImageWriter¼¯ºÏ¡£
Java SE 6ÖеÄImageIOĬÈÏÖ§³ÖJPG£¬BMP£¬PNG£¬GIFµÈ¸ñʽ£¬Ò²¿ÉÒÔͨ¹ý·Ç±ê×¼Àà¿âÌí¼ÓImageIO¶ÔͼÏñ¸ñʽµÄÖ§³Ö£¬±ÈÈç°²×°JAI_ImageIO¡£
/** *//**
* ½«BufferedImage±àÂëÊä³ö³ÉÓ²ÅÌÉϵÄͼÏñÎļþ¡£
* Õâ¸ö·½·¨Ö§³ÖµÄ±àÂë¸ñʽÒÀÀµÔËÐл·¾³ÀïImageIOÒѾע²áImageWriter¼¯ºÏ¡£
*
* @param file±àÂëÊä³öµÄÄ¿±êͼÏñÎļþÃû£¬ÎļþÃûµÄºó׺ȷ¶¨±àÂë¸ñʽ¡£
* @param image´ý±àÂëµÄͼÏñ¶ÔÏó¡£
* @param quality±àÂëѹËõµÄ°Ù·Ö±È¡£
* @param progressListener±àÂë½ø¶ÈµÄ¼àÌýÆ÷¡£
* @return·µ»Ø±àÂëÊä³ö³É¹¦Óë·ñ¡£
*/
public boolean writeImageFile(File file, BufferedImage image, int quality, IIOWriteProgressListener progressListener) ...{
try ...{
String suffix = getFileSuffix(file);if (suffix == null) ...{
return false;
}Iterator it = ImageIO.getImageWritersBySuffix(suffix);
if (it.hasNext()) ...{FileImageOutputStream fileImageOutputStream = new FileImageOutputStream(file);
ImageWriter iw = (ImageWriter) it.next();ImageWriteParam iwp = iw.getDefaultWriteParam();
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
iwp.setCompressionQuality(quality / 100.0f);iw.setOutput(fileImageOutputStream);
iw.addIIOWriteProgressListener(progressListener);
iw.write(null, new javax.imageio.IIOImage(image, null, null), iwp);
iw.dispose();fileImageOutputStream.flush();
fileImageOutputStream.close();
}
} catch (Exception ex) ...{
ex.printStackTrace();
return false;
}
return true;
}
getFileSuffix() ¹ËÃû˼Ò壬ÊÇÈ¡µÃÎļþºó׺µÄ·½·¨¡£/** *//**
* È¡µÃÎļþºó׺¡£
* Èç¹ûÎļþÊäÈë²ÎÊýΪ null ·µ»Ø null¡£
*
* @param file
* @return
*/
public String getFileSuffix(File file) ...{
if (file == null) ...{
return null;
}
return getFileSuffix(file.getName());
}
/** *//**
* È¡µÃÎļþºó׺¡£
* Èç¹ûÎļþÃûÊäÈëΪ null ·µ»Ø null£»
* Èç¹ûûÓÐÈ¡µÃºó׺Ôò·µ»Ø ""¡£
*
* @param fileName
* @return
*/
public String getFileSuffix(String fil
Ïà¹ØÎĵµ£º
JavaÓïÑÔµÄÊäÈëÊä³ö¹¦ÄÜÊÇÊ®·ÖÇ¿´ó¶øÁé»îµÄ£¬ÃÀÖв»×ãµÄÊÇ¿´ÉÏÈ¥ÊäÈëÊä³öµÄ´úÂë²¢²»ÊǺܼò½à£¬ÒòΪÄãÍùÍùÐèÒª°ü×°Ðí¶à²»Í¬µÄ¶ÔÏó¡£ÔÚJavaÀà¿âÖУ¬IO²¿·ÖµÄÄÚÈÝÊǺÜÅÓ´óµÄ£¬ÒòΪËüÉæ¼°µÄÁìÓòºÜ¹ã·º:±ê×¼ÊäÈëÊä³ö£¬ÎļþµÄ²Ù×÷£¬ÍøÂçÉϵÄÊý¾ÝÁ÷£¬×Ö·û´®Á÷£¬¶ÔÏóÁ÷£¬zipÎļþÁ÷....±¾ÎĵÄÄ¿µÄÊÇΪ´ó¼Ò×öÒ»¸ö¼òÒªµÄ½éÉÜ¡£
¡¡¡¡Á ......
ÀûÓÃJava Reflect»úÖƱàдÍòÄÜtoString()·½·¨:
package com.accp.test.filed;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
publ ......
Êý¾Ý½á¹¹ºÍËã·¨
ðÅÝ£ºÃ¿´Î±È½Ï¶¼¿ÉÕÒ³ö×î´ó»ò×îСµÄ£¬ÓÐÐòµÄÔÚ×îÓÒ±ß
Ñ¡ÔñÅÅÐò£ºÓÐÐòµÄÔÚ×î×ó±ß
²åÈëÅÅÐò£ºËٶȱÈðÅÝ¿ìÒ»±¶£¬±ÈÑ¡ÔñÒ²¿ì¡£
µÝ¹é
µ÷ÓÃ×ÔÉí
ººÅµËþÎÊÌ⣺
/**
* @ººÅµËþµÄÎÊÌâ
*/
......
Java´úÂ룺
import java.util.regex.*;
public final class RegExpValidator
{
/**
* ÑéÖ¤ÓÊÏä
* @param ´ýÑéÖ¤µÄ×Ö·û´®
* @return Èç¹ûÊÇ·ûºÏµÄ×Ö·û´®,·µ»Ø <b>true </b>,·ñÔòΪ <b>false </b>
*/
public static boolean isEmail(String str)
{
......