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.

Rogue
  • 751
  • 1
  • 17
  • 36
  • 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. – Andreas Feb 08 '16 at 22:13
  • Exactly... :( I have no control on the server, i just have to deal with it on the client... – Rogue Feb 08 '16 at 22:14
  • possible duplicate: http://stackoverflow.com/questions/7743534/filter-search-and-replace-array-of-bytes-in-an-inputstream – Navid777 May 19 '17 at 05:33

0 Answers0