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

javaÎļþÉÏ´«·½·¨

ÎļþÉÏ´«·½·¨£¨Ò»´ÎÉÏ´«Ò»¸öÎļþ£¬¶à¸öÎļþµÄ»°£¬Çëдѭ»·µ÷Óã©
Upload.uploadFile(theFile, filePath)
˵Ã÷£º
theFile£ºÀàÐÍÊÇFormFile
filePath£ºactionÖз¾¶»ñÈ¡·½·¨    this.getServlet().getServletContext().getRealPath("/")
µ÷Óô˷½·¨·µ»ØÎļþÉÏ´«ºóµÄ·¾¶Ãû
ÉÏ´«¶à¸öÎļþʱ£¬ÇëÉèÖÃÿ¸öÎļþÖ®¼ä1ÃëµÄÑÓ³Ù£¬·ñÔòÎļþ»á±»¸²¸Ç
package common.com;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.struts.upload.FormFile;
/**
 * @author lsc
 * ÎļþÉÏ´«
 */
public class Upload {
 /**
  * ÎļþÉÏ´«
  * @param theFile£¨FormFile£©
  * @param filePath(actionÖз¾¶»ñÈ¡·½·¨£ºthis.getServlet().getServletContext().getRealPath("/") )
  * @return
  */
 public static String uploadFile(FormFile theFile , String filePath) {
  String fileName = theFile.getFileName();//È¡µÃÉÏ´«µÄMsdsÎļþÃû
  try{
         String hardPath = "";
            /*
             * È¡µ±Ç°ÏµÍ³Â·¾¶D:\Tomcat5\webapps\coka\ ÆäÖÐcoka Ϊµ±Ç°context
             */
            //String filePath = this.getServlet().getServletContext().getRealPath("/");
            File savePath = new File(filePath + "UploadFiles\\");
           if (!savePath.exists()) {
            savePath.mkdir();
           }
           if


Ïà¹ØÎĵµ£º

Eclipse Java×¢ÊÍÄ£°åÉèÖÃÏê½â

Eclipse Java×¢ÊÍÄ£°åÉèÖÃÏê½â
src url£ºhttp://blog.csdn.net/ahhsxy/archive/2009/09/11/4542682.aspx
ÉèÖÃ×¢ÊÍÄ£°åµÄÈë¿Ú£º Window->Preference->Java->Code Style->Code Template È»ºóÕ¹¿ªComments½Úµã¾ÍÊÇËùÓÐÐèÉèÖÃ×¢Ê͵ÄÔªËØÀ²¡£ÏÖ¾Íÿһ¸öÔªËØÖðÒ»½éÉÜ£º
Îļþ(Files)×¢ÊͱêÇ©£º
/**  
......

JavaÖØÐ´ÓëÖØÔØ

 
ÓÐʱºò£¬ÀàµÄͬһÖÖ¹¦ÄÜÓжàÖÖʵÏÖ·½Ê½£¬µ½µ×²ÉÓÃÄÇÖÖʵÏÖ·½Ê½£¬È¡¾öÓÚµ÷ÓÃÕß
¸ø¶¨µÄ²ÎÊý¡£ÀýÈçÔÓ¼¼Ê¦ÄÜѵÁ·¶¯Î¶ÔÓÚ²»Í¬µÄ¶¯ÎïÓв»Í¬µÄѵÁ··½Ê½¡£
       
public void train
(Dog dog){
       
//
ѵÁ·Ð¡¹·Õ¾Á¢£¬ÅŶӣ¬×öËã ......

javaµÄ¼¸ÖÖ¶ÔÏó(PO,VO,DAO,BO,POJO)½âÊÍ

   Ò»¡¢PO:
persistant object
³Ö¾Ã¶ÔÏó,¿ÉÒÔ¿´³ÉÊÇÓëÊý¾Ý¿âÖеıíÏàÓ³ÉäµÄjava¶ÔÏó¡£×î¼òµ¥µÄPO¾ÍÊǶÔÓ¦Êý¾Ý¿âÖÐij¸ö±íÖеÄÒ»Ìõ¼Ç¼£¬¶à¸ö¼Ç¼¿ÉÒÔÓÃPOµÄ¼¯ºÏ¡£POÖÐÓ¦¸Ã²»°ü
º¬ÈκζÔÊý¾Ý¿âµÄ²Ù×÷¡£
   ¶þ¡¢VO
:value
objectÖµ¶ÔÏó¡£Í¨³£ÓÃÓÚÒµÎñ²ãÖ®¼äµÄÊý¾Ý´«µÝ£¬ºÍPOÒ»ÑùÒ²Êǽö½ö°üº¬Êý¾ ......

java(Web)ÖÐÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶ÎÊÌâ×ܽá

java(Web)ÖÐÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶ÎÊÌâ×ܽá
ǰÑÔ£º
 Ç°Ò»¶Îʱ¼ä£¬ÓÉÓÚÔÚ´¦ÀíWebÓ¦ÓÃϵÄÎļþ´´½¨ÓëÒÆ¶¯µÈ£¬Òò´ËÉæ¼°µ½ºÜ¶à¹ØÓÚjava
ÖÐÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶µÈÎÊÌ⡣ͬʱ£¬¶ÔÓÚWebÓ¦ÓÃÖеÄÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶£¬ÒÔ¼°Java.io.File
ÀàѧϰÁËһϡ£Ò²ÕÒÁËһЩ×ÊÁÏ¡£Ï£Íû´ó¼ÒÓöµ½ÀàËÆµÄÎÊÌ⣬¿ÉÒÔ¸üÓÐЧµÄ½â¾ö¡£
========= ......

¶þ²æÊ÷µÄjava¹¹ÔìËã·¨

²Î¿¼ÍøÉϵÄһЩ×ÊÁÏ£¬×Ô¼ºÑжÁÁËÒ»·¬£¬ÓÃjava¹¹ÔìÁËÒ»¸ö¶þ²æÊ÷À࣬²¢´øÓвâÊÔµÄmain·½·¨£¬ÈçÓв»×ãÇë´ó¼Ò¶à¶àÖ¸½Ì¡£
/**
* ¶þ²æÊ÷¹¹ÔìËã·¨
* ¶þ²æÊ÷¶¨Ò壺ÊǶÈΪ2µÄÓÐÐòÊ÷£¬ËüµÄÌØµãÊÇÿ¸ö½ÚµãÖÁ¶àÓÐÁ½¿Ã×ÓÊ÷
* ÎÒÃǵÄËã·¨¾ÍÊǸù¾Ý¶þ²æÊ÷µÄµÝ¹é¶¨Òå¶øÀ´£¬ÏÂÃæÊǶþ²æÊ÷µÄµÝ¹é¶¨Ò壺
* n(n>=0)¸ö½ÚµãµÄÓÐÏÞ¼¯¡£Ëü ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ