将文件作为inputstream读取时如何获取Excel文件名

尝试读取excel(*。xlsx)作为二进制inputstream。 目前使用OPCPackage(Apache POI)打开inputstream,然后使用XSSFReader读取表单。

但是在读取inputstream的时候,我们怎么能find自己的文件名。 任何帮助/build议表示赞赏

既然你是从inputstream获得input,你不能得到文件名。但如果你使用的文件对象,那么你可以得到的名字。

例:

File file = new File("/path/to/your/file.xlsx"); String fileName = file.getName().split(".")[0]; // "." is the file ext.