✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
import java.io. *;
public class Program {
public static void main (String [] args) {
String text = "Hello world!"; // рядок для запису
try (FileOutputStream fos = new FileOutputStream ( "C: /SomeDir/notes.txt"))
{byte [] buffer = text.getBytes ();// новий рядок в байти
fos.write (buffer, 0, buffer.length);}
catch (_____ex) {
System.out.println (ex.getMessage ());}
System.out.println ( "The file has been written");}}