java - Splitting array on new line -
i submitting following input through stdin:
4 2
30 one
30 two
15 three
25 four
my code is:
public static void main(string[] args) throws ioexception { bufferedreader stdin = new bufferedreader(new inputstreamreader(system.in)); string submittedstring; system.out.flush(); submittedstring = stdin.readline(); zipfpuzzle mysolver = new zipfpuzzle(); mysolver.gettopsongs(submittedstring); }
which calls:
//bringing public string gettopsongs(string mystring) { setup(mystring); calculatequality(); qualitysort(); return titlesort(); }
which calls
public void setup(string mystring) { string tempstring = mystring; //creating array each element line string[] lineexplode = tempstring.split("\\n+"); //setting numsongsalbum , songstoselect string[] firstline = lineexplode[0].split(" "); numsongsalbum = integer.parseint(firstline[0]); songstoselect = integer.parseint(firstline[1]); system.out.println(lineexplode.length); //etc }
however, reason lineexplode.length returns value 1... suggestions?
kind regards, dario
string[] lineexplode = tempstring.split("\\n+");
the argument string#split string contains regular expression
Comments
Post a Comment