The code is right for me except one thing. I don't read the file from the server. I create the file using POI-HSSF, so in the first line: InputStream is = new FileInputStream(file); file is read from the server, but I have created and store for example in FileOutputStream.