Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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³ÌÐòÈ«¾Ö¼üÅ̼àÌýʼþ


// ×¢²áÓ¦ÓóÌÐòÈ«¾Ö¼üÅÌʼþ, ËùÓеļüÅÌʼþ¶¼»á±»´Ëʼþ¼àÌýÆ÷´¦Àí.
Toolkit tk = Toolkit.getDefaultToolkit();
tk.addAWTEventListener(new MyAWTEventListener(), AWTEvent.KEY_EVENT_MASK);
class MyAWTEventListener implements AWTEventListener {
    private boolean controlPressed = fal ......

java±¾¼Í

JavaÐéÄâ»úµÄÆðÔ´Óë¹¹Ôì
µ±ÎÒÃÇ˵µ½“Java”Õâ¸ö´ÊµÄʱºò£¬Ö¸µÄÊÇËĸöÏ໥¹ØÁªµÄ¸ÅÄJavaÓïÑÔ¡¢Java API¡¢Java ClassÎļþ¸ñʽ¡¢JavaÐéÄâ»ú¡£Õû¸öJavaÌåϵÊÇ»ùÓÚJava ÐéÄâ»ú¹¹ÔìµÄ£¬ÕýÒòΪÈç´Ë£¬²ÅÄÜʵÏÖJavaµÄ°²È«ÐÔºÍÍøÂçÒƶ¯ÐÔ¡£Java²¢·ÇÊǵÚÒ»¸ö²ÉÓÓÐéÄâ»ú”¸ÅÄîµÄÌåϵ£¬µ«È´ÊǵÚÒ»¸öµÃµ½¹ã·ºÔ ......

Java¹ýÂËÆ÷ÑéÖ¤µÇ¼Óû§

1.Ê×ÏÈдһ¸öȨÏÞ¹ýÂËfilterÀà,ʵÏÖFilter½Ó¿Ú
/*Ê×ÏÈдһ¸öȨÏÞ¹ýÂËfilter*/
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.FilterChain;
import ......

javaÖÐÖØдequals·½·¨

import java.util.Date;
class Dog{
 private String name;
 private Date birthday;
 
 
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public Date getBirthday() {
  return b ......

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ºÅ