Commit 4d9938b7 by yao.xiao

关闭流

parent 4b87a854
......@@ -15,10 +15,7 @@ import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.*;
import java.net.InetAddress;
import java.util.Date;
......@@ -43,15 +40,17 @@ public class AgmsInsurerServiceImpl implements AgmsInsurerService {
SealUploadResponseVO responseVO = new SealUploadResponseVO();
boolean success = true;
String message = ZHBErrorConfig.getErrorInfo("800000");
InputStream in = null;
FileOutputStream out = null;
try {
byte[] bytes = sealFile.getBytes();
InputStream in = new ByteArrayInputStream(bytes);
in = new ByteArrayInputStream(bytes);
InetAddress address = InetAddress.getLocalHost();
File outFile = new File(signImage + sealFile.getOriginalFilename());
System.out.println(address.getHostAddress());
System.out.println("http://" + address.getHostAddress() + signImage + sealFile.getOriginalFilename());
// File outFile = new File("D:\\"+sealFile.getOriginalFilename());
FileOutputStream out = new FileOutputStream(outFile);
out = new FileOutputStream(outFile);
byte[] bts = new byte[1024];
int len = 0;
while ((len = in.read(bts)) != -1) {
......@@ -78,6 +77,20 @@ public class AgmsInsurerServiceImpl implements AgmsInsurerService {
success = false;
message = ZHBErrorConfig.getErrorInfo("830025");
e.printStackTrace();
}finally {
try {
assert in != null;
in.close();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
assert out != null;
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
responseVO.setCommonResult(new CommonResult(success, message));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment