Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Get response stream using java API.

Get response stream using java API.

Scheduled Pinned Locked Moved C#
csharpjavajsonhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Prateek G
    wrote on last edited by
    #1

    Hi, I want to pass one url and get response stream from that url.How can I do this with any java method. Earlier I was using HttpWebRequest and HttpWebResponse APIs of System.net namespace. But now since I want output in stream of sbyte[] I want to use any java method. Please help me. Prateek Gupta.

    M 1 Reply Last reply
    0
    • P Prateek G

      Hi, I want to pass one url and get response stream from that url.How can I do this with any java method. Earlier I was using HttpWebRequest and HttpWebResponse APIs of System.net namespace. But now since I want output in stream of sbyte[] I want to use any java method. Please help me. Prateek Gupta.

      M Offline
      M Offline
      M LN Rao
      wrote on last edited by
      #2

      Response.getOutputStream() - But what is this parady?

      Intelligence is measured by common sense not by how many scholarly books you read.

      P 1 Reply Last reply
      0
      • M M LN Rao

        Response.getOutputStream() - But what is this parady?

        Intelligence is measured by common sense not by how many scholarly books you read.

        P Offline
        P Offline
        Prateek G
        wrote on last edited by
        #3

        I want to use any java method which takes url and give me response of server. Why I am doing so is I am using java.util.zip which takes sbyte[] earlier I was getting byte[] (when I was using httpWebRequest and httpWebResponse) and if i was trying to make this conversion byte[] to sbyte[] file which i m getting from server is getting damaged.So what I am thinking is if I can send url to any java method which can give me response back we can directly add this output stream to zipinputstream. The code which I was using earlier is HttpWebRequest hReq = (HttpWebRequest)HttpWebRequest.Create(ReqUrl); HttpWebResponse hResp = (HttpWebResponse)hReq.GetResponse(); Stream str = hResp.GetResponseStream(); MemoryStream output = new MemoryStream(); int nBytesRead = 0; byte[] buffer = new byte[1024]; while ((nBytesRead = str.Read(buffer, 0, 1024)) > 0) { //Read the stream until the end of file in chunks of 1024 bytes output.Write(buffer, 0, nBytesRead);//Write the currently read bytes into the MemoryStream } hResp.Close(); output.Close(); return output.ToArray(); // This .ToArray() method gives me byte[] while i want sbyte[] Any equivalent method in java can help me out. Prateek Gupta.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups