项目部署到服务器,但是需要下载文件到服务器上,不知道路径怎么写。

String newImageName = "F://video/" + uuid + ".jpg"

FileOutputStream fos = new FileOutputStream(new File(newImageName));

下载文件到服务器上?????

package test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

public class TestQwehyc {

/**
 * @param args
 * @throws IOException 
 */

     public static void main(String[] args) {
         String destFile="D:\\生成的文件.doc";//生成文件的路径 当然也可以生成咋项目里 方便下载
         //根据Word模板导出单个Word文档
         Map<String, String> map=new HashMap<String, String>();

         map.put("name", "冯");
         map.put("sex", "女");
         map.put("idCard", "200010");
         map.put("year1", "2000");
         map.put("month1", "07");

         //注意biyezheng_moban.doc文档位置,此例中为应用根目录
         HWPFDocument document=new TestQwehyc().replaceDoc("D:/Users/TpSourect/Workspaces/MyEclipse 10/TTest/src/biyezheng_moban.doc", map);
         ByteArrayOutputStream ostream = new ByteArrayOutputStream();
         try {
             document.write(ostream);
             //输出word文件
             OutputStream outs=new FileOutputStream(destFile);
             outs.write(ostream.toByteArray());
             outs.close();
         } catch (IOException e) {
             e.printStackTrace();
         }

     }


     /**
      * 
      * @param destFile
      * @param fileCon
      */
     public void exportDoc(String destFile,String fileCon){
         try {
             ByteArrayInputStream bais = new ByteArrayInputStream(fileCon.getBytes());
             POIFSFileSystem fs = new POIFSFileSystem();
             DirectoryEntry directory = fs.getRoot(); 
             directory.createDocument("WordDocument", bais);
             FileOutputStream ostream = new FileOutputStream(destFile);
             fs.writeFilesystem(ostream);
             bais.close();
             ostream.close();

         } catch (IOException e) {
             e.printStackTrace();
         }
     }

     /**
      * 读取word模板并替换变量
      * @param srcPath
      * @param map
      * @return
      */
     public HWPFDocument replaceDoc(String srcPath, Map<String, String> map) {
         try {
             // 读取word模板
             FileInputStream fis = new FileInputStream(new File(srcPath));
             HWPFDocument doc = new HWPFDocument(fis);
             // 读取word文本内容
             Range bodyRange = doc.getRange();
             // 替换文本内容
             for (Map.Entry<String, String> entry : map.entrySet()) {
                 bodyRange.replaceText("${" + entry.getKey() + "}", entry
                         .getValue());
             }
             return doc;
         } catch (Exception e) {
             e.printStackTrace();
             return null;
         }
     }

 }

POI 导出 你可以参考一下 从服务器下载

是上传吧?下载服务器脚本语言可以实现,跟项目没多大关系,想实现服务器下载可以考虑从项目上生成脚本文件并且运行。上传就简单多了,http请求就行了。