Downloading a file in Linux
- From: Grzesiek <grzesiek.wilanowski@xxxxxxxxx>
- Date: Sun, 19 Aug 2007 12:19:42 -0700
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?
.
- Follow-Ups:
- Re: Downloading a file in Linux
- From: Thomas Hawtin
- Re: Downloading a file in Linux
- From: Daniel Pitts
- Re: Downloading a file in Linux
- From: Grzesiek
- Re: Downloading a file in Linux
- Prev by Date: Re: PixelGrabber question
- Next by Date: New Software and a new update
- Previous by thread: app path
- Next by thread: Re: Downloading a file in Linux
- Index(es):
Relevant Pages
|