亚洲免费人人妻人人,cao78在线视频,福建一级毛片,91精品视频免费观看,高清另类图片操逼,日本特黄特色大片免费看,超碰欧美人人澡曰曰澡夜夜泛

Struts2基本讀寫法上傳文件 -電腦資料

電腦資料 時間:2019-01-01 我要投稿
【www.msguai.com - 電腦資料】

   

String savepath = ServletActionContext.getServletContext().getRealPath("/upload");System.out.println(savepath);    try {    File desc = new File(savepath,picFileName);    //FileUtils.copyFile(pic, desc);  《--采用此種方法以下均可省略,較簡單    InputStream is = new FileInputStream(pic);    OutputStream s = new FileOutputStream(desc);    byte[] buf = new byte[1024];    int len;    while((len=is.read(buf))!=-1){        os.write(buf);    }    is.close();    os.close();    } catch (Exception e) {        e.printStackTrace();    }

    易錯點:若寫成--》is.read(buf)<0 將無法讀取過來, 但是會在目標路徑生成一個零字節(jié)文件!

最新文章