I put 1, 2, 3 then I want only 1 and 3 to be view.
BufferedReader br = new BufferedReader (new FileReader("medicine.txt"));
while(line= br.readLine() != null) {
System.out.print("line+"br.readLine()):
}
Maybe you should split your line with the character ','
while(line = br.readLine() != null) {
String[] splittedLine = line.split(",");
System.out.println(splittedLine[0] + "-" + splittedLine[1]);
}
You can solve this in a myriad of ways but if you always want to skip "2", something like this should work:
while(line = br.readLine() != null) {
if (line.equals("2")) {
continue;
}
System.out.print("line: " + line);
}
您可以使用计数器并检查计数器是否到达您的行。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.