You might want to call a flush() before you close it. But I'm not sure if the same would not be called before it is closed(), automatically. I think it makes sense for the JVM to call it so that data is not lost.
Joined: Jul 17, 2008
Thanks for the reply.
I have added output.flush(); befire closing....still not working properly
What, exactly, are you trying to do? The code looks somewhat like servlet code (implying that you're trying to stream a file to the client), but since you're using a File object, the operation is entirely local to the servlet container.
You probably want to use "+file.getName()" instead of just "+file".
If this is indeed a web app, then note that web apps do not have a concept of a default directory - which means that you need to use absolute paths, not relative paths like you have now.