Code for downloading files from server
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rajagopal_Sampathu
Posted On:   Wednesday, May 2, 2001 11:14 AM

How do I have to write to download files from a server? In many sites there is a download link, which when clicked asks to open or save the file. What is the code behind that?

Re: Code for downloading files from server

Posted By:   jonathan_wasson  
Posted On:   Wednesday, May 2, 2001 12:23 PM

Create the file on the server... i.e. for a .jsp...




<%! public boolean writeToFile(String fileName, String fileContent){

boolean success;

try {

File outputFile= new File(fileName);

FileWriter fw=

new FileWriter (outputFile);

BufferedWriter bw =

new BufferedWriter(fw);

bw.write(fileContent);

bw.close();

fw.close();

success = true;

}

catch (Exception e) {

success = false;

};

return success;

}

%>






and then provide an href link to it on a preceding web page.
About | Sitemap | Contact