This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Downloading the document
It's not a secret anymore!