Привет всем, пожалуйста, я получил немного ошибки, поэтому я пытаюсь импортировать файл Excel с весенней загрузкой и React js, но в моем бэкэнде я получил ошибку
Конструктор BufferedOutputStream (FileOutputStream) не определен
метод:
@RequestMapping(value="/upload", method=RequestMethod.POST)
public @ResponseBody ResponseEntity<String> handleFileUpload(@RequestParam("name") String name,
@RequestParam("file") MultipartFile file) throws Exception{
if (name.contains("/")) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("Folder separators not allowed.");
} else if (name.contains("/")) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("Relative pathnames not allowed.");
} else if (!name.endsWith(".jar")) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("File type not allowed. Must be a Jar file type ending in '.jar'.");
}
if (!file.isEmpty()) {
try {
byte[] bytes = file.getBytes();
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(name)));
stream.write(bytes);
stream.close();
return ResponseEntity.ok("File " + name + " uploaded.");
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(e.getMessage());
}
} else {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("You failed to upload " + name + " because the file was empty.");
}
}
}
я получаю сообщение об ошибке в этой строке:
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(name)));