Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
7.9k views
in Java FTP by (580 points)
I had a directory over a machine with 25k number of files.
Using DirectoryListCallback interface implementation, i just wanted to list first 500 files only. I did so
but after completion of this listing, i got an error
com.enterprisedt.net.ftp.FTPException: 426 Failure writing network stream.
ERROR [STDERR] at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:1235)
ERROR [STDERR] at com.enterprisedt.net.ftp.FTPClient.a(FTPClient.java:3760)
ERROR [STDERR] at com.enterprisedt.net.ftp.FTPClient.dirDetails(FTPClient.java:3604)



So what is this related to and how this problem can be resolved.
Connection mode is set to PASSIVE.

7 Answers

0 votes
by (162k points)
Did you read all the files? That's an amazing number in one directory btw.
0 votes
by (580 points)
Not all the files. It listed only 500 number of files as per the logs provided by implementing class.

And yes, this number even could go up further beyond 1 lac or so. Because there will be multiple users at multiple locations transferring these files to a single directory.

One more thing to note here: when i dont use DirectoryListCallback interface, i dont really get this error. dirdetails simply lists all 25k number of files
0 votes
by (162k points)
When using this callback you still need to read the entire list.
0 votes
by (580 points)
Hello Sir,
Thanks for your reply.
In reply to your answer "does that mean Even if i am using DirectoryListCallback, i have to list all those files present in the directory".
As per my understanding your API document contradicts your current statement.
Please elaborate if i am wrong.

And what i wanted is
"LISTING only 500 files following a particular pattern out of 25k files present in a directory".
so is this possible using any of your api without the need of reading all those file names present
0 votes
by (162k points)
Could you post the bit of API documentation that you think says this.
0 votes
by (580 points)
Hello Sir,
May be my understanding and actual statement is different still i am posting it as i though it could serve my purpose
Anyway here it is

dirDetails

public void dirDetails(java.lang.String dirname,
DirectoryListCallback lister)
throws java.io.IOException,
FTPException,
java.text.ParseException

Description copied from interface: FTPClientInterface
List a directory's contents via a callback. The callback is notified for each directory entry, meaning they can be processed individually. It also avoids out of memory problems if the directory is huge, and an array of thousands of FTPFile objects would otherwise be returned.

Specified by:
dirDetails in interface FTPClientInterface

Parameters:
dirname - name of directory (some servers permit a filemask)
lister - callback to be notified of errors
Throws:
java.io.IOException
FTPException
java.text.ParseException


0 votes
by (162k points)
What this means is that each directory entry is returned individually in the callback, instead of 25,000 at one time in an array (which could cause memory problems). You still have to download all the entries or you will get a server error as you've seen.

Categories

...