1

I have an InputStream coming from the internet, using this code :

URL url = new URL(sharedPreferences.getString("profile" + drawer.getCurrentSelectedPosition() + "Url", ""));
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setDoInput(true);
connection.connect();
BufferedInputStream inputStream = new BufferedInputStream(connection.getInputStream());

What i want is to convert the & to & in order for the XML to be valid and not cause an error when parsing. I'd also like not to convert the inputstream to string (and use String.replaceAll()) in order to be more memory efficient.

Is there a way ? Thanks.

3
  • 1
    Are you saying that the server is sending you bad XML, and that you want to try to auto-fix it on-the-fly? I'd strongly suggest that you re-think that. Commented Feb 8, 2016 at 22:13
  • Exactly... :( I have no control on the server, i just have to deal with it on the client... Commented Feb 8, 2016 at 22:14
  • possible duplicate: stackoverflow.com/questions/7743534/… Commented May 19, 2017 at 5:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.