这是我的代码(servlet)。
boolean isMultiPart = ServletFileUpload.isMultipartContent(request);
if (isMultiPart) {
ServletFileUpload upload = new ServletFileUpload();
try {
FileItemIterator itr = upload.getItemIterator(request);
while (itr.hasNext()) {
FileItemStream item = itr.next();
FILE_NAME = item.getName();
InputStream stream = item.openStream();
if (item.isFormField()) {
String value = Streams.asString(stream, "UTF-8");
}
}
try {
FileInputStream excelFile = new FileInputStream(new File(FILE_NAME));
Workbook workbook = new XSSFWorkbook(excelFile);
Sheet datatypeSheet = workbook.getSheetAt(0);
Iterator<Row> iterator = datatypeSheet.iterator();
} catch (Exception adfasdasd) {
adfasdasd.printStackTrace();
}
} catch (FileUploadException ex) {
// Logger.getLogger(PropertyController.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException exp) {
// Logger.getLogger(PropertyController.class.getName()).log(Level.SEVERE, null, exp);
}
FileInputStream excelFile = new FileInputStream(new File(FILE_NAME)); 要做到这一点,我需要上传文件的完整路径。我怎么得到它?