PrintWriter
Data / CompositeDescription
Writes text to a file. Create with createWriter(). Always call close() or flush() when done.
Syntax
PrintWriter* writer = createWriter("output.txt")
Parameters
None
Returns
PrintWriterMethods
| print(T v) | Writes a value without a newline |
| println(T v) | Writes a value followed by a newline |
| println() | Writes a blank line |
| flush() | Flushes the buffer to disk |
| close() | Closes the file |
Related
Under the Hood
From Processing.h:
class PrintWriter {
std::ofstream f;
public:
explicit PrintWriter(const std::string& path) : f(path) {}
template<typename T> void print(const T& v) { f << v; }
template<typename T> void println(const T& v) { f << v << "\n"; }
void println() { f << "\n"; }
void flush() { f.flush(); }
void close() { f.close(); }
};
Under the Hood
From Processing.cpp:
PrintWriter* PApplet::createWriter(const std::string& path){ return new PrintWriter(path);