java - System.out.println always outputs HASH(0x........) -
the system.out.println statement below outputs logcat hash reference "hash(0x....)" whether or not specify variable printed "line" or "line.tostring()". how print actual string value?
url object=new url(url); httpurlconnection con = (httpurlconnection) object.openconnection(); con.setdooutput(true); con.setdoinput(true); con.setrequestproperty("content-type", "application/json"); con.setrequestproperty("accept", "application/json"); try { con.setrequestmethod("post"); } catch (protocolexception e) { e.printstacktrace(); } outputstreamwriter wr; try { wr = new outputstreamwriter(con.getoutputstream()); wr.write(json.tostring()); wr.flush(); } catch (ioexception e) { e.printstacktrace(); } int httpresult = con.getresponsecode(); if (httpresult == httpurlconnection.http_ok) { bufferedreader br = new bufferedreader(new inputstreamreader(con.getinputstream(),"utf-8")); string line; while ((line = br.readline()) != null) { system.out.println("line: " + line.tostring()); } br.close(); }
there's nothing wrong code. replace code above loop simpler, like:
fileinputstream fstream = new fileinputstream("somefile"); bufferedreader br = new bufferedreader(new inputstreamreader(fstream,"utf-8")); string line; while ((line = br.readline()) != null) { system.out.println("line: " + line); } br.close();
and see content of file.
note didn't need .tostring()
because variable string.
what suspect here server sending compressed body, , each line hash because definition of compression, in hex.
the content json, compressed improve size , speed.
Comments
Post a Comment