This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Downloading the document

 
prasanth chiru
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic