Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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));
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #print #outputstream #console #java
ADD COMMENT
Topic
Name
7+4 =