Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

java ±àÂë´¦Àí¹ý³Ì ÒýÓÃ

ÕâÊÇһƪ¹ØÓÚ±àÂëµÄÎÄÕÂдµÄºÜºÃ!
   ÊÀ½çÉϵĸ÷µØÇø¶¼Óб¾µØµÄÓïÑÔ¡£µØÇø²îÒìÖ±½Óµ¼ÖÂÁËÓïÑÔ»·¾³µÄ²îÒì¡£ÔÚ¿ª·¢Ò»¸ö¹ú¼Ê»¯³ÌÐòµÄ¹ý³ÌÖУ¬´¦ÀíÓïÑÔÎÊÌâ¾ÍÏԵúÜÖØÒªÁË¡£
¡¡¡¡ÕâÊÇÒ»¸öÊÀ½ç·¶Î§ÄÚ¶¼´æÔÚµÄÎÊÌ⣬ËùÒÔ£¬JavaÌṩÁËÊÀ½çÐԵĽâ¾ö·½·¨¡£±¾ÎÄÃèÊöµÄ·½·¨ÊÇÓÃÓÚ´¦ÀíÖÐÎĵ쬵«ÊÇ£¬Íƶø¹ãÖ®£¬¶ÔÓÚ´¦À ......

java action ·¾¶ÎÊÌâ

StringBuilder path = new StringBuilder(request.getScheme());
  path.append("://").append(request.getServerName());
  path.append(":").append(request.getServerPort()).append(request.getContextPath());
  System.out.println("***********path:" + path);
  Syste ......

javaÕýÔò±í´ïʽȥµôÆ¥Åä¿Õ¸ñ¿ÕÐÐ

java µÄÈ¥µô¿Õ¸ñ¿ÕÐеÄÀý×Ó£º
 String so = "haolong,    hei eip,      "
            +"ting,         " +
         & ......

SUSE10ϰ²×°java JDK1.6

Ò»¡¢°²×°
´´½¨°²×°Ä¿Â¼£¬ÔÚ/usr/javaϽ¨Á¢°²×°Â·¾¶£¬²¢½«Îļþ¿¼µ½¸Ã·¾¶Ï£º
# mkdir /usr/java
1¡¢jdk-6u11-linux-i586.bin Õâ¸öÊÇ×Ô½âѹµÄÎļþ£¬ÔÚlinuxÉϰ²×°ÈçÏ£º
# chmod 755 jdk-6u11-linux-i586.bin
# ./jdk-6u11-linux-i586.bin
ÔÚ°´ÌáʾÊäÈëyesºó£¬jdk±»½âѹ¡£
³öÏÖÒ»ÐÐ×Ö£ºDo you aggree to the ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ