Java Utililty Methods Stream Close

List of utility methods to do Stream Close

Description

The list of methods to do Stream Close are organized into topic(s).

Method

voidcloseFile(FileWriter fw)
closeFile Close a text file
fw.flush();
fw.close();
voidcloseFile(final Closeable p_closeable)
close File
if (p_closeable != null) {
    p_closeable.close();
voidcloseFile(PrintStream ps)
close File
ps.flush();
ps.close();
voidcloseFile(RandomAccessFile file)
close File
if (file == null)
    return;
try {
    file.close();
} catch (IOException e) {
voidcloseFiles(Closeable... closeables)
Silently closes multiple resources.
for (Closeable closeable : closeables) {
    close(closeable);
voidcloseFileWriter(BufferedWriter bw)
close File Writer
try {
    bw.close();
} catch (IOException e) {
    e.printStackTrace();
voidcloseFileWriter(FileWriter file)
close File Writer
file.flush();
file.close();
voidcloseGZipStream(GZIPOutputStream outStream)
Closes given gzip output stream.
if (outStream != null) {
    try {
        outStream.finish();
        outStream.close();
    } catch (IOException e) {
voidcloseHTML(String pageTemplate, PrintStream out)
close HTML
out.print(pageTemplate.substring(pageTemplate.indexOf(TEMPLATE_CONTENT) + TEMPLATE_CONTENT.length()));
booleancloseIgnoreExceptions(Closeable c)
Closes a data stream, ignoring any IOExceptions thrown
if (c != null) {
    try {
        c.close();
    } catch (IOException e) {
        e.printStackTrace();
        return false;
return true;