因此,我正在阅读一个文件,其中包含我在前面代码中写到的约会。我想在文本文件中搜索某个日期的约会并将其添加到ArrayList中,但当BufferedReader遍历它时,它会跳过其他行...这是我的代码
public ArrayList<String> read(int checkDay, int checkMonth, int checkYear) {
ArrayList<String> events = new ArrayList<String>();
BufferedReader in = null;
String read;
try {
in = new BufferedReader(new FileReader("calendar.txt"));
while ((read = in.readLine()) != null) {
read = in.readLine();
String[] split = read.split(",");
System.out.println(read);
if (split[1].equals(Integer.toString(checkDay)) && split[2].equals(Integer.toString(checkMonth)) && split[3].equals(Integer.toString(checkYear))) {
events.add(split[0] + " : " + split[1] + "/" + split[2] + "/" + split[3]);
}
}
} catch (IOException e) {
System.out.println("There was a problem: " + e);
e.printStackTrace();
} finally {
try {
in.close();
} catch (Exception e) {
}
}
return events;
}
你在读这行两遍。
while ((read = in.readLine()) != null) { // here
read = in.readLine(); // and here
问题内容: 从CSV读取数据时,它会跳过第二行。我有两个CSV文件,一个用于用户,一个用于属性-密钥ID是user。 我与以下用户一起运行 每个奇数编号都在工作,并且检测到用户已登录,而第二个奇数编号正在跳过。我阅读了一下,但我不认为我有.nextLine()正在像此链接中那样跳过,但是我只在星期五开始使用CSV和BufferedReader! 问题答案: 它跳过第二行,因为您在每次迭代中都读取两
这里是我的源代码:
我有一个名为“add”的方法,它将字符串作为参数,并使用bufferedwriter将其写入文件。完成此操作后,bufferedwriter将被刷新。 在另一个方法“read”中,我遍历文件中的行,但这些行是空的(因此我不能打印它们)。
当使用扫描仪对象从文本文件中读取时,我希望它跳过文件中的第一行。我该怎么做?
为什么我的程序在读取文件时忽略零?例如,以下是文件中的数字: 这是我的输出: 这是我的代码:
问题内容: 我有一个笨拙的csv文件,我需要跳过第一行来阅读它。 我正在使用python / pandas轻松做到这一点 但是我不知道如何在Go中做到这一点。 错误: : 问题答案: 读取csv文件时跳过第一行 例如, 输出: