Этот код перестает работать после передачи первого файла. Помогите разобраться в чем дело.
@Override
protected Void doInBackground(Void... voids){
FTPClient client = new FTPClient();
FileInputStream fis = null;
OutputStream outputStream;
byte[] buffer = new byte[BUFFER_SIZE];
int totalBytesRead = 0;
try {
client.connect(host,port);
client.login(username, password);
client.setFileType(FTP.BINARY_FILE_TYPE);
for (File file : uploadFile){
fis = new FileInputStream(file);
outputStream = client.storeFileStream(file.getName());
int bytesRead;
while ((bytesRead = fis.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
int percentCompleted = (totalBytesRead * 100 / length);
Log.d("PROGRESS", String.valueOf(totalBytesRead)+" "+String.valueOf(percentCompleted));
onProgressUpdate(totalBytesRead);
}
}
client.logout();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}