马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
代码如下:/**
* author :LaoGu
* time :2021/9/8
* purpose: 通过File文件演示Stream操作
***/
#include<FS.h>
String file_name = "/LaoGu/notes.txt"; //被读取的文件位置和名称
void setup() {
Serial.begin(9600);
Serial.println("");
//启动SPIFFS
if(SPIFFS.begin()){
Serial.println("SPIFFS started!");
}else{
Serial.println("SPIFFS failed to start!");
}
File dataFile = SPIFFS.open(file_name,"w");
dataFile.println("Hello IOT World.");
dataFile.close();
Serial.println("Finished Writing data to SPIFFS");
Serial.print("Try to find IOT in ");
Serial.println(file_name);
dataFile = SPIFFS.open(file_name,"r");
if(dataFile.find("IOT")){
Serial.print("Found IOT in file: ");
Serial.println(file_name);
}
Serial.println("User readString to get contents of dataFile after find");
Serial.println(dataFile.readString());
dataFile.close();
}
void loop() {}
查看串口监视器:
|