首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件开发 >

图片写下文件夹

2012-06-30 
图片写入文件夹private static void copy(File src, File dst) {try {InputStream in nullOutputStream

图片写入文件夹

private static void copy(File src, File dst) {try {    InputStream in = null;    OutputStream out = null;    try {in = new BufferedInputStream(new FileInputStream(src), BUFFER_SIZE);out = new BufferedOutputStream(new FileOutputStream(dst), BUFFER_SIZE);byte[] buffer = new byte[BUFFER_SIZE];while (in.read(buffer) > 0) {    out.write(buffer);}    } finally {if (null != in) {    in.close();}if (null != out) {    out.close();}    }} catch (Exception e) {    e.printStackTrace();}    }


调用:

if (myFile != null && myFile.size() > 0) {

    File imageFile1 = new File(ServletActionContext.getServletContext().getRealPath("images") + "/" + "t01.jpg");
  
   
    if (myFile.get(0) != null) {
copy(myFile.get(0), imageFile1);
    }
}

热点排行