Why do I need to convert inputstream to string? To implement the encryption function, the input of the encryption function is string.
Public static string inputstream2string (inputstream in) throws ioexception {stringbuffer out = new stringbuffer (); byte [] B = new byte [4096]; int N; while (n = in. read (B ))! =-1) {out. append (new string (B, 0, n);} log. I ("String Length", new INTEGER (Out. length ()). tostring (); Return out. tostring ();}
Through various getinputstream methods, you can convert httpurlconnection, input text stream, and so on to string. Of course, you can also convert it to byte []
Public static byte [] inputstreamtobyte (inputstream is) throws ioexception {bytearrayoutputstream bytestream = new bytearrayoutputstream (); int ch; while (CH = is. Read ())! =-1) {bytestream. Write (CH);} byte imgdata [] = bytestream. tobytearray (); bytestream. Close (); Return imgdata ;}