This
out.write(dis.readLine());
out.newLine();
is your problem. Not every file type is line-separated. I would simply perform a byte-by-byte copy in order to preserve the contents. Perhaps you could check out the many IOUtils copy()
methods available ?