I am really stuck now by using ftp. I am using commons library and some other jars which are needed for commons.

Currently I made, also took some code from tutorial site the ftpLayer so it would be easier to connect and some other things.
So i follow this schema: connect, login - when start upload download set the passivemode on, binary for transfering, get the stream(Input or Output), close the I/o and then ftp disconnect.

Problem: This schema works for when i am working with one, but i wanted to upload and download many files. But when used this schema it sometimes work and sometimes not. But there's really big flaw in my transfer process. When use for many times transfer scheama is

nextfile: <- this label like you have seen it in some BASIC code
loop starts
connectlogin
passivmode on
binary on

start upload

i/o close
ftp disconnect
GOTO nextfile
//////////////////////////////////////
but when i used, got error, this solution should be right
nextfile: <- this label like you have seen it in some BASIC code
connectlogin
passivmode on
binary on
loop starts
start upload
i/o close

GOTO nextfile
ftp disconnect