I am using following code for uploading file. it works fine but the problem is that in uploading process arbitrary on a file it got hanged (No idea what is the reason).
-May be file is too long.
-May be Connection is not working fine.
but it remains hanged and finally i have to terminate it manually. so if there is any thing wrong then how can i get recognize time out doesn't matter whatever the reason just skip that file with some error.
FTPClient client = new FTPClient();
FileInputStream fis = null;
try {
client.connect("32.178.10.121");
client.login("XXX", "XXX");
//
// Create an InputStream of the file to be uploaded
//
File f = new File("D:\\FileFolder");
if (f.isDirectory())
{
File[] listFiles = f.listFiles();
for (int i = 0; i < listFiles.length; i++)
{
String filename = listFiles[i].getName();
fis = new FileInputStream(filename);
client.storeFile(filename, fis);
}
}
//
// Store file to server
//
client.logout();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}