Downloading a file in Linux



Hi,

I use the following function to download a jar file from my website:

public synchronized boolean copyFileFromWeb(){

try
{
URL url = new URL(sourceURL);
URLConnection urlC = url.openConnection();
InputStream is = url.openStream();
System.out.print("Copying resource (type: " +
urlC.getContentType());
Date date=new Date(urlC.getLastModified());
System.out.flush();
FileOutputStream fos=null;
fos = new FileOutputStream(destinationPath);
int oneChar, count=0;
while ((oneChar=is.read()) != -1)
{
fos.write(oneChar);
count++;
}
is.close();
fos.close();
System.out.println(count + " byte(s) copied");
return true;
}
catch (Exception e){
System.err.println(e.toString());
}
return false;

}


In Windows XP it works perfectly, but in Linux it works very slow and
the downloaded file is corrupted! What is wrong?

.



Relevant Pages

  • Re: Downloading a file in Linux
    ... I use the following function to download a jar file from my website: ... URL url = new URL; ... two similar machines on the same network subnet? ...
    (comp.lang.java.programmer)
  • Re: Downloading a file in Linux
    ... I use the following function to download a jar file from my website: ... URL url = new URL; ... URLConnection urlC = url.openConnection; ... I found a link about downloading a file in Linux ...
    (comp.lang.java.programmer)
  • Re: Downloading a file in Linux
    ... I use the following function to download a jar file from my website: ... URL url = new URL; ... It's not a great idea to catch Exception rather than the actual exception type you wish to catch. ... When you say the file is corrupt, ...
    (comp.lang.java.programmer)
  • Re: [ANN] Where is M13?
    ... > file that opens fine but has no application in it, ... As stated on the download page, ... Sounds like your browser is automatically expanding the jar file when it ... What OS and browser are you using? ...
    (sci.astro.amateur)
  • Re: Jar file download (and I use spammy signatures)
    ... > me that a JAR file is being downloaded with a rapidly progressing ... I quickly close the window. ... status bar noting the applet download. ... "certain public sites" so my supposition cannot be verified. ...
    (microsoft.public.win2000.general)