emm,第一次接触邮箱这一块的东西,使用的是腾讯企业邮箱,网络也没有问题,用流写入磁盘的时候,4m大小的文件半小时都写不完,请指教一下;
这是我保存附件的代码,in 是附件的InputStream传进来的
File strorefile = new File(newPath); BufferedOutputStream bos = null; BufferedInputStream bis = null; try { if (!strorefile.exists()) { strorefile.getParentFile().mkdirs(); } strorefile.createNewFile(); DecimalFormat dec = new DecimalFormat("#0"); bos = new BufferedOutputStream(new FileOutputStream(strorefile)); bis = new BufferedInputStream(in); int c; while ((c = bis.read()) != -1) { bos.write(c); bos.flush(); } } catch (Exception e) { log.info("************保存附件失败************"); log.info(e.getMessage(), e); } finally { bos.close(); bis.close(); }