Going nearly crazy

In the getCommandLine() function you seem to be building String s2 by adding characters to it

s2 = s2 + ch;

but then you return String s1 from the function

return s1;