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

public void sort(int[] array) {
  for(int i=0; i<array.length; i++) {
    boolean flag = true;
    for(int j=0; j<array.length-i-1; j++) {
      if(array[j]>array[j+1]) {
        int tmp = ar ......

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 ......

³¹µ×ת±äÁ÷£¬µÚ 2 ²¿·Ö£ºÓÅ»¯ Java ÄÚ²¿ I/O


Ìæ»»×Ö½ÚÊý×éÁ÷ºÍ¹ÜµÀÁ÷
ÎĵµÑ¡Ïî
<tr
valign="top"><td width="8"><img alt="" height="1" width="8"
src="//www.ibm.com/i/c.gif"/></td><td width="16"><img alt="" width="16"
he ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ