JAVA创建临时文件IO

private File getTransFormedIns(InputStream ins,int width, int height) throws Exception {
// TODO Auto-generated method stub
File file = null;
OutputStream os = null;
try {
file = File.createTempFile("tmp",".jpg",new File(System.getProperty("java.io.tmpdir")));
os = new FileOutputStream(file);
imageService.transformImageWithoutWaterMark(ins, os, width, height);
ins.close();
os.close();
} catch (IOException e) {
try {
if (ins != null)
ins.close();
if (os != null)
os.close();
} catch (IOException e1) {
e.printStackTrace();
}
e.printStackTrace();
throw e;
}
return file;
}

原文地址:https://www.cnblogs.com/zhuzhiq/p/5395128.html