Hi everyone,

I am currently trying to do an application that does the upload as well the download of files from a http server that needs authentication.
The thing is i am not very sure where to begin and i am open to any suggestions.

Basically what i am trying to upload is a html file onto the http server and also have the capability to download back that file back to my computer if i need it. The server i am using does not support ftp so using the sun's ftp classes are out but i am not sure if there are classes that exist for the uploading and downloading of files from a http server.

I am not using servlets but trying to upload or download a simple html file to http server from a java application

Sample codings as well as informative links would be helpfull

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West

hi Richard

yesterday you had posted regarding connecting to a pop3 server and viewing mails. you had problem in getting the attachments. I am really interested in the topic, when i tried to run the same program the program says waiting.....
I tried to send mails to my maild id that time, but still the same result. should i have to alter any settings? I am not sure where I am going wrong.

To your current question, i will try on my own and get back to you if I find any solution.

thanks
srinivas

Hi everyone,

Srinivas, the code on the mail thread seems to work for me. I use an smtp server that was provided by my isp and everthing works okay except that i can only read text e-mails and nothing more. I can't even get the attachments in. I really don't know why.

Are you using the class correctly??
Are you putting the arguments in their correct way??

Richard West

To download ...

public class HTTPStuff
{
public static Downloader(String fetchUrl, String saveAs)
{
  try
  {
    URL url = new URL(fetchUrl);
    InputStream in = url.openStream();
    FileOutputStream out = new FileOutputStream(saveAs);
    bye[] buff = new byte[4*1024]; //4k buffer
    int bytesRead;
    while((bytesRead=in.read(buf))!=-1)
    {
        out.write(buf,0,bytesRead);
    }
    in.close();
    out.close();
  }
    catch(MalformedURLException e)
    {
        e.printStackTrace();
    }
    catch(IOException e)
   {
        e.printStackTrace();
   }

not sure about uploading...this code should work but might not be 100% correct. I didn't have a compiler handy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.