posted 19 years ago
Hi guys!
Im trying to open a connection with a server, and download a jar file and reconstruct it on the client system running the application. When the file downloads the jar is corrupt. Im assumed it was because I have downloaded in ascii format but Im using input and output streams for the process. Ive checked the jar file on the server and it is intact.
Any Ideas?
try{
URL fileurl = new URL("ftp://SERVERNAME/FILE.jar");
URLConnection urlC = fileurl.openConnection();
InputStream is = fileurl.openStream();
FileOutputStream fos= new FileOutputStream("C:\\SOMEDIR\\FILE.jar");
int count = 0;
int numb;
while( (numb=is.read())!=-1){
count++;
fos.write(numb);
}
is.close();
fos.close();
System.out.println(count +" byte(s) copied");
}catch(Exception ftpe){
System.out.println(ftpe);
}