aspose file tools*
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
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
 
Similar Threads
Downloading a document.
Namespace using Axis
Java Program to Convert Oracle database to a single SQL file.
Display byte[] in browser
Searching a XSL-file to transform docbook.xml to word.xml or openoffice.xml