You're initializing the String
source will a null
value so it's value is translated to the literal "null" on the first String
concatenation in the while
loop.
Use an empty String
instead
String source = "";
or better use a StringBuilder
.