Invalid Http Response

Asked

Viewed 29 times

0

I have the following block of code

public void read( String url ){
       try{
            urlNormal = new URL("http://"+url+"/sistema.cgi?lermc=0,33");
            URLConnection conn = urlNormal.openConnection();
            BufferedReader input = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String s = null;
            Map<String, String> valores = new HashMap<>();
            int i = 0;
            String nova = "";

            List<String> dadosRecuperados = new ArrayList<String>();
            String[] dadosSeparados = null;
            if (null != (s = input.readLine())) {
                nova = s.replace("[", "").replace("]", "");
                dadosSeparados = nova.split(",");
            }

            for( int j = 0; j< dadosSeparados.length; j++ ){
                System.out.println(dadosSeparados[j]);
            }

               // valores.put( campos[i], s );
            //}
        }
        catch(java.net.MalformedURLException ex){
            System.out.println(ex.getMessage());
        }
        catch(java.io.IOException ex){
            System.out.println(ex.getMessage());
        }
    }

When I read a url it gives the following message:

Invalid Http Response

The data that is returned from the url is like this:

[127.63,28.87,3684.71,2621.41,0.71,0.00,0.00,0.00,2589.45,0.00,127.23,29.70,3779.10,-2439.51,-0.65,0.00,0.00,0.00,2886.24,0.00,126.52,29.33,3711.14,-580.26,-0.16,-1.00,-1.00,-1.00,3665.50,59.58,29.30,38.60]

I wonder what’s wrong

  • It would be nice if you explained what the method does so one doesn’t have to read to find out. If the problem is in the answer then or maybe it is calling with wrong parameters or it is a problem in the service.

  • I think it’s the format

  • What returns this url?

  • [127.63,28.87,3684.71,2621.41,0.71,0.00,0.00,0.00,2589.45,0.00,127.23,29.70,3779.10,-2439.51,-0.65,0.00,0.00,0.00,2886.24,0.00,126.52,29.33,3711.14,-580.26,-0.16,-1.00,-1.00,-1.00,3665.50,59.58,29.30,38.60]

  • This is what it should return even and Voce is having trouble reading or the answer is coming wrong?

  • You can test with any other URL?

  • Yeah. The other one worked

  • Who shows this data is the Angolan

  • You can add the error Stacktrace to your question?

  • I had it before, but I removed it

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.