Reputation: 16081
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?
Upvotes: 0
Views: 41
Reputation: 381
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();
Upvotes: 1