java - Buffered Reader read text until character -
i using buffered reader read in file filled lines of information. of longer lines of text extend more 1 line buffered views them new line. each line ends ';'
symbol. wondering if there way make buffered reader read line until reaches ';'
return whole line string. here how using buffered reader far.
string currentline; while((currentline = reader.readline()) != null) { // trim newline when comparing linetoremove string[] line = currentline.split(" "); string fir = line[1]; string las = line[2]; for(int c = 0; c < players.size(); c++){ if(players.get(c).getfirst().equals(fir) && players.get(c).getlast().equals(las) ){ system.out.println(fir + " " + las); string text2 = currentline.replaceall("[.*?]", ".150"); writer.write(text2 + system.getproperty("line.separator")); } } }
it easier scanner
, can set delimiter:
scanner scan = new scanner(new file("/path/to/file.txt")); scan.usedelimiter(pattern.compile(";")); while (scan.hasnext()) { string logicalline = scan.next(); // rest of logic }
Comments
Post a Comment