private String fileUpload() {
try {
InputStream in = new FileInputStream(new File("D:\\temp\\b.sql"));
if (in != null) {
byte[] buffer = new byte[1024];
ByteArrayOutputStream out = new ByteArrayOutputStream();
int len = 0;
while ((len = in.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
String str = out.toString();
return str;
}
} catch (Exception e) {
}
return null;
}
@RequestMapping(value = "/sgcu")
public String upload(HttpServletRequest req, HttpServletResponse resp, MultipartFile file) {
StringBuilder sb = new StringBuilder();
String fn = file.getOriginalFilename();
System.out.println(fn);
String enter = "\r\n";
sb.append(fn).append(enter);
InputStream in = null;
try {
in = file.getInputStream();
if (in != null) {
byte[] buffer = new byte[1024];
ByteArrayOutputStream out = new ByteArrayOutputStream();
int len = 0;
while ((len = in.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
String str = out.toString();
return sb.append(str).toString();
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}