Given an initialized string variable filename write a sequence of statements that append the line all is well to the file whose name is given by the variable make sure that the data written to the file has been flushed from its buffer and that any system resources used during the course of running these statements have been released. Do not concern yourself with any possible exceptions here—assume they are handled elsewhere.

Respuesta :

Answer:

Details below...

Explanation:

import java.io.*;  

import java.util.Locale;  

//program to demonstrate PrintWriter  

class PrintWriterDemo {  

public static void main(String[] args)  

 {  

 String s="GeeksforGeeks";  

 // create a new writer  

 PrintWriter out = new PrintWriter(System.out);  

 char c[]={'G','E','E','K'};  

 

 //illustrating print(boolean b) method

 out.print(true);  

 

 //illustrating print(int i) method  

 out.print(1);  

 

 //illustrating print(float f) method  

 out.print(4.533f);  

 

 //illustrating print(String s) method  

 out.print("GeeksforGeeks");  

 out.println();  

 

 //illustrating print(Object Obj) method  

 out.print(out);  

 out.println();  

 

 //illustrating append(CharSequence csq) method  

 out.append("Geek");  

 out.println();  

 

 //illustrating checkError() method  

 out.println(out.checkError());  

 

 //illustrating format() method  

 out.format(Locale.UK, "This is my %s program", s);  

 

 //illustrating flush method  

 out.flush();  

 

 //illustrating close method  

 out.close();  

}  

}