Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Network stream to byte array  RSS feed

 
gavin goh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Experts out there.

Is it possible if i create a byte array from the network stream?
 
Rob Spoor
Sheriff
Posts: 21087
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are we talking about Java this time? Because your previous thread was about C#.

In Java, you can copy the contents as described in the second piece of code in http://faq.javaranch.com/java/AvailableDoesntDoWhatYouThinkItDoes. The InputStream will be the InputStream from the socket (or any other network source), the OutputStream will be a ByteArrayOutputStream. When you're done, you can call toByteArray on that last one to get a byte[].
 
gavin goh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My apologies to all, I'm working on C# not java . My bad
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!