BufferReader的方法

我有一个正在使用BufferedReader阅读的文本文件。它仅捕获并存储单词 oshane ,但我希望 oshane.png 被缓冲区读取。你能告诉我我在做什么错吗?
Name.txt: photo:oshane.png

这是我的方法:

try {
    while ((str = reader.readLine()) != null) {
        int pos = str.indexOf(":");
        String temp = str.substring(pos + 1,str.length());
        if ((str.contains("photo"))) {
            photo = temp;
        }
jsbuyun26 回答:BufferReader的方法

使用Split()方法代替indexOf()

while ((str = reader.readLine()) != null) {
     if ((str.contains("photo:"))) {
      name = str.split("\\:")[1];
      }
}
本文链接:https://www.f2er.com/3056611.html

大家都在问