Home » Java » Convert FileOutputStream to File in java-Exceptionshub

Convert FileOutputStream to File in java-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

How could I write into File file = new File('test.txt');
I did something like this:

OutputStream os = new FileOutputStream(file, true);
os.write("data".getBytes(), 0, "data".length());
os.flush();
os.close();

But I need to use os as File again, how could I convert it back to File?

How to&Answers: