I created a file using FileOutputStream and it is an excel file (using HSSF Liberary)
FileOutputStream fileOut = new FileOutputStream(text+".xls");
then I write what I need in my excel file (workbook) and then close the file
workbook.write(fileOut);
fileOut.flush();
fileOut.close();
After closing it I need to display the path of the file to user, (I know that it creates in the folder of my application but I still need to display it to user, maybe via joption/message box)
I tried this :
String absolutePath = fileOut.getAbsolutePath();
JOptionPane.showMessageDialog(null, absolutePath);
but it shows error and it says that it cannot find the method "getAbsolutePath". what should I do ? is there anyway that I can get this path ?
new File(text+".xls")
then you can use all the properties ofFile
, likegetAbsolutePath
– GleesonFileOutputStream
doesn't have a method caledgetAbsolutePath
, as determined by the OP's error "cannot find the method" – GleesonFileOutputStream
can also take aFile
as a reference to write to.FileOuputStream
will write to where ever you tell it to, which right now is{user.dir}/{text}.xls
(or the current working directory). – Gleeson