#includeusing namespace std; int main() { PrintStream ps(System.out); ps.println("Hello World!"); // prints output to console return 0; }
#includeThis example shows how to use the PrintStream class to write output to a file using an instance of the 'ofstream' class. Package Library: Java Standard Library - java.io package.using namespace std; int main() { ofstream outFile("outputfile.txt"); PrintStream ps(outFile); ps.println("This is an example of output to file."); // writes output to file outFile.close(); return 0; }