I’m attempting to create an xlsx workbook object with Apache-POI by passing my .xlsx as a resource stream: I can successfully instantiate the workbook when passing my template.xlsx through a FileInputStream and a local file path, but when I pass the resources stream I get an exception: The .xlsx I’m passing shouldn’t be zipped, but maybe that’s how it works
Tag: stream
Understanding getInputStream and getOutputStream
Here is a code I have marked the statements that I have problems understanding. I do not understand what OutputStream object out will hold when it is assigned s.getOutputStream() and what is the need of passing buf to out by out.write(buf). I have learned Input and Output Streams using files but I do not understand getinputstream and outputstreams. I have
How to redirect ProcessBuilder’s output to a string?
I am using the following code to start a process builder.I want to know how can I redirect its output to a String. I tried using ByteArrayOutputStream but it didn’t seem to work. Answer Read from the InputStream. You can append the output to a StringBuilder:
Android Reading from an Input stream efficiently
I am making an HTTP get request to a website for an android application I am making. I am using a DefaultHttpClient and using HttpGet to issue the request. I get the entity response and from this obtain an InputStream object for getting the html of the page. I then cycle through the reply doing as follows: However this is
platform-independent /dev/null output sink for Java
Other than an anonymous class (new OutputStream() { … }), can anyone suggest a moral equivalent of new FileOutputStream(“/dev/null”) that also works on Windows? In case someone’s wondering ‘what’s this for?’ I have a program that does a consistency analysis on a file. It has a ‘verbose’ option. When the verbose option is on, I want to see a lot
Listen to a shoutcast with Android
since quite some time I’m trying to listen to .pls files (shoutcasts). I have to say that I failed horrible. Since StreamFurious can do it it must be possible. First I tried to connect to the shoutcast via sockets (TCP and UDP) –> failed. I couldn’t even receive one byte from the server. I’m at the verge of tears. I
Play WAV file backward
I’m making Braid in Java. If you rewind the time, the sound plays backward. How to play a WAV file backwards? Maybe with a stream with something like previous()? On the site of Braid can you see what I mean. Update: Solved! See my own post. Answer I solved it by myself And then:
Most efficient way to create InputStream from OutputStream
This page: http://blog.ostermiller.org/convert-java-outputstream-inputstream describes how to create an InputStream from OutputStream: Other alternatives are to use PipedStreams and new threads which is cumbersome. I do not like the idea of copying many megabytes to new in memory byte array. Is there a library that does this more efficiently? EDIT: By advice from Laurence Gonsalves, i tried PipedStreams and it turned
Java Large Files Disk IO Performance
I have two (2GB each) files on my harddisk and want to compare them with each other: Copying the original files with Windows explorer takes approx. 2-4 minutes (that is reading and writing – on the same physical and logical disk). Reading with java.io.FileInputStream twice and comparing the byte arrays on a byte per byte basis takes 20+ minutes. java.io.BufferedInputStream
How 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?