操人视频99青青av|亚洲a极淫交3P毛片电影|精品蜜桃人妻天天久|国产精品色婷婷免费|正规av网站在线免费观看|国产精品高清在线观看|免费成人网站在线|97干色五月天最黄三级无码片|在线免费观看黄色毛片A片|日韩无码视频一二三四区

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

電腦資料 時(shí)間:2019-01-01 我要投稿
【m.emoneyp.cn - 電腦資料】

   

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();    }

    易錯(cuò)點(diǎn):若寫成--》is.read(buf)<0 將無法讀取過來, 但是會(huì)在目標(biāo)路徑生成一個(gè)零字節(jié)文件!

最新文章