|
@@ -18,7 +18,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.transaction.Transactional;
|
|
import javax.transaction.Transactional;
|
|
-import java.io.*;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.OutputStream;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@@ -146,19 +147,14 @@ public class RwdeditVersionService {
|
|
|
|
|
|
OutputStream out = null;
|
|
OutputStream out = null;
|
|
try {
|
|
try {
|
|
- ByteArrayInputStream stream = getStream(sqlList);
|
|
|
|
- resp.reset();// 清空输出流
|
|
|
|
String resultFileName = URLEncoder.encode(fileName, "UTF-8");
|
|
String resultFileName = URLEncoder.encode(fileName, "UTF-8");
|
|
|
|
+ resp.reset();// 清空输出流
|
|
resp.setCharacterEncoding("UTF-8");
|
|
resp.setCharacterEncoding("UTF-8");
|
|
- // 设定输出文件头
|
|
|
|
resp.setHeader("Content-disposition", "attachment; filename=" + resultFileName);
|
|
resp.setHeader("Content-disposition", "attachment; filename=" + resultFileName);
|
|
- // 定义输出类型
|
|
|
|
resp.setContentType("application/txt");
|
|
resp.setContentType("application/txt");
|
|
out = resp.getOutputStream();
|
|
out = resp.getOutputStream();
|
|
- byte[] buff = new byte[4096];
|
|
|
|
- int size = 0;
|
|
|
|
- while ((size = stream.read(buff)) != -1) {
|
|
|
|
- out.write(buff, 0, size);
|
|
|
|
|
|
+ for (String sql : sqlList) {
|
|
|
|
+ out.write(sql.getBytes());
|
|
}
|
|
}
|
|
out.flush();
|
|
out.flush();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -173,18 +169,5 @@ public class RwdeditVersionService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- public ByteArrayInputStream getStream(List<String> list) throws IOException {
|
|
|
|
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
|
- DataOutputStream out = new DataOutputStream(baos);
|
|
|
|
- for (String sql : list) {
|
|
|
|
- out.writeBytes(sql + "\r\n");
|
|
|
|
- }
|
|
|
|
- byte[] bytes = baos.toByteArray();
|
|
|
|
- ByteArrayInputStream tInputStringStream = new ByteArrayInputStream(bytes);
|
|
|
|
- baos.close();
|
|
|
|
- out.close();
|
|
|
|
- return tInputStringStream;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|