File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
src/plugins/ftp/src/android/com/foxdebug/ftp Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -684,20 +684,22 @@ public void run() {
684684 ftp .setFileType (FTP .BINARY_FILE_TYPE );
685685
686686 Log .d ("FTPUpload" , "Destination " + remoteFilePath );
687- OutputStream outputStream = ftp .storeFileStream (remoteFilePath );
688- if (outputStream == null ) {
689- callback .error ("File not found." );
690- return ;
691- }
692687
693- InputStream inputStream = new FileInputStream (localFile );
694- byte [] buffer = new byte [1024 ];
695- int bytesRead = -1 ;
696- while ((bytesRead = inputStream .read (buffer )) != -1 ) {
697- outputStream .write (buffer , 0 , bytesRead );
688+ try (
689+ InputStream inputStream = new FileInputStream (localFile );
690+ OutputStream outputStream = ftp .storeFileStream (remoteFilePath )
691+ ) {
692+ if (outputStream == null ) {
693+ callback .error ("File not found." );
694+ return ;
695+ }
696+
697+ byte [] buffer = new byte [1024 ];
698+ int bytesRead = -1 ;
699+ while ((bytesRead = inputStream .read (buffer )) != -1 ) {
700+ outputStream .write (buffer , 0 , bytesRead );
701+ }
698702 }
699- outputStream .close ();
700- inputStream .close ();
701703
702704 if (!ftp .completePendingCommand ()) {
703705 ftp .logout ();
You can’t perform that action at this time.
0 commit comments