java - Scanner class skips over whitespace -
i using nested scanner loop extract digit string line (from text file) follows:
string str = teststring; scanner scanner = new scanner(str); while (scanner.hasnext()) { string token = scanner.next(); // here each token used } the problem code skip spaces " ", need use "spaces" too. can scanner return spaces or need use else?
my text file contain this:
0 011 abc d2d sdwq sda those blank lines contains 1 " " each, , " " need returned.
use scanner's hasnextline() , nextline() methods , you'll find solution since allow capture empty or white-space lines.
Comments
Post a Comment