java - Issue with an Android FTP Client -
i´m trying download file local android project ftp
this method
@override protected file doinbackground(void... params) { file filebar = new file(mlocaldir, mfilenamebar); boolean descargado = false; ftpclient ftpclient = null; try { ftpclient = new ftpclient(); ftpclient.setconnecttimeout(10000); ftpclient.connect(server, 21); ftpclient.enterlocalpassivemode(); ftpclient.setfiletype(ftp.binary_file_type); if (ftpclient.login(muser, mpass)) { ftpclient.changeworkingdirectory("/almacen"); fileoutputstream fileoutputstreambar; fileoutputstreambar = new fileoutputstream(filebar, false); outputstream outputstreambar = new bufferedoutputstream(fileoutputstreambar); fileoutputstream fileoutputstreampec; fileoutputstreampec = new fileoutputstream(filepec, false); outputstream outputstreampec = new bufferedoutputstream(fileoutputstreampec); descargado = ftpclient.retrievefile(mfilenamebar, outputstreambar); } } catch (ioexception e) { system.out.println(e.tostring()); fileart = null; } { if (ftpclient != null && ftpclient.isconnected()) try { ftpclient.logout(); } catch (ioexception ignored) { } if (ftpclient != null) try { ftpclient.disconnect(); } catch (ioexception ignored) { } } return (descargado ? fileart : null); }
the method works correctly, or @ least think so. download requested file, instead of occupying 32kb occupies 24kb. not understand why happens. if can give me hand grateful
make sure close output streams gracefully before function returns. can try explicitly call flush() or close(). seems method return before saving data.
see this answer
Comments
Post a Comment