peek()

描述

回傳檔案未讀資料中的第一個字元,回傳後不把該字元認為是已讀。由於沒有把回傳的字元認為是已讀,所以如果沒有呼叫 read() 每次呼叫 peek() 都會得到同一個字元。

peek() 是從 Stream 繼承而來。

語法


file.peek()

參數

file:被 SD.open() 回傳的 File 物件

回傳

int:回傳檔案未讀資料中最前面的字元,如果沒有可讀資料則回傳 -1

See Also

available()
read()
write()
Stream.peek()


函式庫參考主頁面

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.