Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of What is the alternative to deprecated the FileUtils.writeStringToFile method? without wasting too much if your time.
The question is published on by Tutorial Guruji team.
The question is published on by Tutorial Guruji team.
I need to write a content to file in a single statement something like FileUtils.writeStringToFile
.
Is there any alternative to it since it is deprecated?
Answer
By going through this documentation, It states that:
Deprecated. 2.5 use writeStringToFile(File, String, Charset) instead Writes a String to a file creating the file if it does not exist using the default encoding for the VM.
You can follow this example:
final File file = new File(getTestDirectory(), "file_name.txt"); FileUtils.writeStringToFile(file, "content", "ISO-8859-1");
You can pass (String) null
in your argument if you don’t want to pass the encoding.
For more information, you can go through the link: Usage link
We are here to answer your question about What is the alternative to deprecated the FileUtils.writeStringToFile method? - If you find the proper solution, please don't forgot to share this with your team members.