0

I have an application that gets data(json) from my webservice(rest). I can successfully get my json. What i did is this:

            try{
            DefaultHttpClient httpClient = new DefaultHttpClient();
            httpClient.setCredentialsProvider(credProvider);
            HttpGet httpGet = new HttpGet(url);

            HttpResponse httpResponse = httpClient.execute(httpGet);
            HttpEntity httpEntity = httpResponse.getEntity();
            inStream = httpEntity.getContent(); 
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(inStream));

            StringBuilder sb = new StringBuilder();
            String line = null;

            while((line = reader.readLine()) != null){
                sb.append(line);
            }

            inStream.close();
            json = sb.toString();
        }catch(Exception e){
            logs...
        }

        // and so on...

But when i try to print my json (String), since I have a url got from that json... my url looks like this something\/image\/myimage.png insted of something/image/myimage.png My problem where and how can i remove the additional "\"in my url. Is this an escape character? Any ideas? It would be great if you share some. Though I'm currently also looking for a fix. But as of now, I can hardly find it.

elL
  • 767
  • 2
  • 14
  • 35
  • check http://stackoverflow.com/questions/3537706/howto-unescape-a-java-string-literal-in-java – Naveen Apr 16 '13 at 05:07

1 Answers1

1

Use str.replaceALL("\\\\","") to remove the escape characters.

shiladitya
  • 2,290
  • 1
  • 23
  • 36
  • and now i wonder why nothing has changed.. it's because that's the way logcat displayed the trace... – elL Apr 16 '13 at 07:06