This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths 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 Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Downloading the document" Watch "Downloading the document" New topic
Author

Downloading the document

prasanth chiru
Greenhorn

Joined: Mar 14, 2004
Posts: 16
Hi,
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.
Thanks
Prabhu Chandrasekaran
Ranch Hand

Joined: Oct 14, 2000
Posts: 36
Hi Prashant,
Check This Code Out
===================
import java.io.*;
class filecopy
{
static FileInputStream fin;
static FileOutputStream fout;
public static void main(String args[]) throws IOException
{
int i;
try
{
fin=new FileInputStream(args[0]);
fout=new FileOutputStream(args[1]);
}
catch(Exception ex)
{
System.out.println(ex);
}
System.out.println("File is Being Copied. Pl. Wait ....\n\n\n\n");
do
{
i=fin.read();
if(i != -1)
{
fout.write((char) i);
}
}
while(i != -1);
fin.close();
fout.close();
}
}
=============================================
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.
Bye.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Downloading the document
 
It's not a secret anymore!