#include "FS.h"
#include "LittleFS.h"
void setup() {
Serial.begin(115200);
Serial.println("Initializing LittleFS...");
// Attempt to mount the filesystem
if (!LittleFS.begin(true)) {
Serial.println("LittleFS Mount Failed");
return;
}
Serial.println("LittleFS Mount Successful");
// Define file path using String
String filePath = "/test.txt";
// Attempt to open the specific file for reading
File file = LittleFS.open(filePath, FILE_READ);
if (!file) {
Serial.println("Failed to open file for reading");
Serial.print("File path: ");
Serial.println(filePath);
return;
}
// Read file content and print it
Serial.printf("Reading content of file: %s\n", filePath.c_str());
while (file.available()) {
String line = file.readStringUntil('\n');
Serial.println(line);
}
file.close();
}
void loop() {
// Nothing to do here
}