File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Downloading the document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Downloading the document" Watch "Downloading the document" New topic

Downloading the document

prasanth chiru

Joined: Mar 14, 2004
Posts: 16
I am developing a web site in which we have a button "Download" in a document, which downloads that document and stores on the clients machine. If anybody has done this earlier or anybody has idea about this please help me.
Prabhu Chandrasekaran
Ranch Hand

Joined: Oct 14, 2000
Posts: 36
Hi Prashant,
Check This Code Out
class filecopy
static FileInputStream fin;
static FileOutputStream fout;
public static void main(String args[]) throws IOException
int i;
fin=new FileInputStream(args[0]);
fout=new FileOutputStream(args[1]);
catch(Exception ex)
System.out.println("File is Being Copied. Pl. Wait ....\n\n\n\n");
if(i != -1)
fout.write((char) i);
while(i != -1);
This program is for copying a file to another name using streams. See if the code solves your problem.
Note : The names of the files are got as arguments in this program.
Post your results back here.

I agree. Here's the link:
subject: Downloading the document
It's not a secret anymore!