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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -