Answers for "print outputstream to console java"

-1

print outputstream to console java

public static Writer createOutputWriter(String fileNm) {
    OutputStream os;
    if (fileNm.equals("") ) { // No file name provided, write to console
        os = System.out;
    }
    // File name provided, write to this file name
    else {
        try {
            os = new FileOutputStream(fileNm);
        }
        catch (FileNotFoundException fe) {
            System.out.println("File not found " + fe.toString());
        }
    }
    return new BufferedWriter(new OutputStreamWriter(os));
}
Posted by: Guest on February-11-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language