0

I am using the java.net.* libraries and need help getting the right type/encoding back from the server. To clarify, I know my server-side program returns the double value of 0.0 and when I do:

OutputStream output = httpConn.getOutputStream()
output.write(query.getBytes(charset))              //where query contains the URL arguments and charset is UTF-8
InputStream response = httpConn.getInputstream();
response.read();

I get the integer value 48 which I know is the ASCII value of 0. What can I do to always ensure that I get a value of type Double?

1 Answer 1

1

InputStream.read() returns the next byte that comes from the stream. Double value types are 64-bits long (8 bytes).

Maybe you need DataInputStream? http://docs.oracle.com/javase/7/docs/api/java/io/DataInputStream.html

InputStream response = new DataInputStream(httpConn.getInputstream());
double result = response.readDouble();
Sign up to request clarification or add additional context in comments.

Comments

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.