我使用FileOutputStream创建了一个文件,它是一个excel文件(使用HSSF Liberary)
FileOutputStream fileOut = new FileOutputStream(text+".xls");
Run Code Online (Sandbox Code Playgroud)
然后我在excel文件(工作簿)中编写我需要的内容,然后关闭文件
workbook.write(fileOut);
fileOut.flush();
fileOut.close();
Run Code Online (Sandbox Code Playgroud)
关闭后我需要向用户显示文件的路径(我知道它在我的应用程序的文件夹中创建,但我仍然需要将其显示给用户,可能通过joption/message box)
我试过这个:
String absolutePath = fileOut.getAbsolutePath();
JOptionPane.showMessageDialog(null, absolutePath);
Run Code Online (Sandbox Code Playgroud)
但它显示错误,它说它找不到方法"getAbsolutePath".我该怎么办 ?无论如何,我可以得到这条路吗?