易截截图软件、单文件、免安装、纯绿色、仅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 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操作EXCEL文件

JXL.JAR 操作Excel文件开源包
这里简单讲些项目中用到的一些方法!(项目的环境是Struts2 hibernate3 resin3 )
 // Excel文件存放路径
String path = ServletActionContext.getServletContext().getRealPath("")+"userfiles\\train_excel\\text.xls";
// 生成Excel文件
WritableWorkbook wwb = Workbook.creat ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号