BufferedReader
Data / CompositeDescription
Reads text from a file line by line. Create with createReader(). Close when done.
Syntax
BufferedReader* reader = createReader("data.txt")
Parameters
None
Returns
BufferedReaderMethods
| readLine() | Reads and returns the next line as std::string. Returns empty string at EOF. |
| ready() | Returns true if the file is open and has more data |
| close() | Closes the file |
Related
Under the Hood
From Processing.h:
class BufferedReader {
std::ifstream f;
public:
explicit BufferedReader(const std::string& path) : f(path) {}
bool ready() const { return f.is_open() && f.good(); }
std::string readLine() { std::string l; std::getline(f,l); return f?l:""; }
void close() { f.close(); }
};
Under the Hood
From Processing.cpp:
BufferedReader* PApplet::createReader(const std::string& path){ return new BufferedReader(path);