Recent Entries 5
- snippet critical 112d agoHow do I convert a Stream into a byte[] in C#?Is there a simple way or method to convert a `Stream` into a `byte[]` in C#?
- pattern critical 112d agoCreating a byte array from a streamWhat is the prefered method for creating a byte array from an input stream? Here is my current solution with .NET 3.5. ``` Stream s; byte[] b; using (BinaryReader br = new BinaryReader(s)) { b = br.ReadBytes((int)s.Length); } ``` Is it still a better idea to read and write chunks of the stream?
- snippet critical 112d agoConvert InputStream to byte array in JavaHow do I read an entire `InputStream` into a byte array?
- snippet critical 112d agoHow do I convert a String to an InputStream in Java?Given a string: ``` String exampleString = "example"; ``` How do I convert it to an `InputStream`?
- snippet critical 112d agoHow do I read / convert an InputStream into a String in Java?If you have a `java.io.InputStream` object, how should you process that object and produce a `String`? Suppose I have an `InputStream` that contains text data, and I want to convert it to a `String`, so for example I can write that to a log file. What is the easiest way to take the `InputStream` and convert it to a `String`? ``` public String convertStreamToString(InputStream is) { // ??? } ```