quando esci dal while s varrà null , quindi richiamando "replaceAll" su essa ottieni ovviamente una NullPointerException