我一直认为文本文件 (.txt) 始终只是长字符串,并且通过包含(不可见的)\n 来创建不同的行。
但是,虽然没有明确说明,但我已经看到对文本文件的引用是字符串数组。
文本文件实际上是字符串数组的集合,每行都是一个单独的字符串吗?
所以,而不是文本文件是:
String = "I went to the supermarket\nI bought a loaf of bread\nI ate the bread later that day"
文本文件真的是:
String[1] = "I went to the supermarket"
String[2] = "I bought a loaf of bread"
String[3] = "I ate the bread later that day"
?