Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javaÎļþ±ÈÀýËõС·Å´ó

1Ê×ÏÈÌí¼ÓÐÞ¸ÄͼƬ¿í¶ÈºÍ¸ß¶ÈµÄ·½·¨
public static void reduceImg(String imgsrc, int widthdist, int heightdist) {
  try {
   File srcfile = new File(imgsrc);
   if (!srcfile.exists()) {
    return;
   }
   // ÔØÈëͼƬÎļþ
   Image src = javax.imageio.ImageIO.read(srcfile);
   int w0 = src.getWidth(null); // µÃµ½Ô´Í¼¿í
   int h0 = src.getHeight(null); // µÃµ½Ô´Í¼³¤
   BufferedImage tag = new BufferedImage((int) widthdist,
     (int) heightdist, BufferedImage.TYPE_INT_RGB);
   // ±£´æÎļþ
   // »æÖÆËõСºóµÄͼ
   tag.getGraphics().drawImage(
     src.getScaledInstance(widthdist, heightdist,
       java.awt.Image.SCALE_SMOOTH), 0, 0, null);
   // tag.getGraphics().drawImage(src.getScaledInstance(widthdist,
   // heightdist, Image.SCALE_AREA_AVERAGING), 0, 0, null);
   // ±êעˮӡ
   // int x = widthdist/10*8; //ˮӡλÖÃ(x,y)
   // int y = heightdist/10*8;
   // jpg_logo( tag , x , y );
   // ÖØÃüÃû²¢Ð½¨Í¼Æ¬
   String oleName = imgsrc.substring(imgsrc.lastIndexOf(".") - 1,
     imgsrc.lastIndexOf("."));
   String newName = oleName + "v";
   String imgdist = imgsrc.replace(oleName, newName);
   // Êä³öµ½ÎļþÁ÷
   FileOutputStream out = new FileOutputStream(imgdist);
   JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
   // ½üJPEG±àÂë
   encoder.encode(tag);
   out.close();
  } catch (IOException ex) {
   ex.printStackTrace();
  }
 }
2°´±ÈÀýÈ¥ËõСͼƬ


Ïà¹ØÎĵµ£º

JAVA¼ÓÃÜËã·¨»ã×ÜÒ»

1. MD5¼ÓÃÜ£¬³£ÓÃÓÚ¼ÓÃÜÓû§ÃûÃÜÂ룬µ±Óû§Ñé֤ʱ¡£
¡¡ ¡¡protected byte[] encrypt(byte[] obj) ...{
¡¡¡¡try ...{
¡¡¡¡MessageDigest md5 = MessageDigest.getInstance("MD5");
¡¡¡¡md5.update(obj);
¡¡¡¡return md5.digest();
¡¡¡¡} catch (NoSuchAlgorithmException e) ...{
¡¡¡¡e.printStackTrace();
¡ ......

°³¾­ÀúµÄJavaÃæÊÔÌâÄ¿

ÌâÄ¿¶¼ºÜ¼òµ¥,µ«ÓÐʱºòÈÃÄãÓñÊÍêÕûµÄд³öÀ´È´²»ÄÇôÈÝÒ×ÁË.
1.±éÀúÎļþ¼Ð(±»Õâ¸öÌâÄ¿¿¼ÁËÁ½´Î)
import java.io.File;
public class ListFile {
public static void main(String[] args) {
// TODO Auto-generated method stub
String path = "C:/Inetpub";
File f = new File(path);
list(f);
}
publ ......

Java Read()×èÈûµÄÒ»ÖÖ´¦Àí·½Ê½

java.io.InputStreamµÄread()·½·¨ÃèÊö£º
        If no byte is available because the end of the stream has been reached, the value -1 is returned.
        µ½´ïÁ÷µÄÄ©Î²Õæ»á·Å»Ø-1Âð£¿
        ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ