Hi,
While reading a file using the code shown below, I’m getting an exception (shown in the screenshot) that I am not able to catch. Can you please suggest what should I do?
File fileToRead = File::getCurrentWorkingDirectory().getChildFile("file.txt");
if (!fileToRead.existsAsFile())
{
DBG("File doesn't exist ...");
}
std::unique_ptr<juce::FileInputStream> input{ fileToRead.createInputStream() };
if (!input->openedOk())
{
DBG("Failed to open file");
// ... Error handling here
}
bool readWholeFile = true;
if (readWholeFile)
{
try {
String content = input->readString();
// ... Do your stuff. New lines are normally seperated by "\n"
DBG(content);
}
catch (const std::exception& e) {
}
}