Is there a way to get the file name from a FileOutputStream
or from FileInputStream
?
My answer comes a little late. I hit the same issue when writing some code.
To get around it, I used a FileOutputStream(File file)
instead of FileOutputStream(String location)
because I can then do file.getAbsolutePath()
. See the example snippet below.
String location = "some.relative.path.txt";
File file = new File(location);
FileOutputStream f = new FileOutputStream(file);
String question = ""+header+"
";
String finalSource = HTMLWrapper.HTML_START+question +htmlContent;
f.write(finalSource.getBytes());
f.flush();
f.close();
System.out.println("The report is now available at"+file.getAbsolutePath());