• Post Reply Bookmark Topic Watch Topic
  • New Topic

read from a file on FTP server  RSS feed

 
amar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using FTPClient to read from a file on the FTP server.

fileStream = ftpClient.retrieveFileStream(File)

buffReader = new BufferedReader(new InputStreamReader(fileStream));

I am using this while loop to read trough the file:

while((lineRead = buffReader.readLine()) != null)
{
if(lineRead.toUpperCase().equals("END"))
break;
}

The end of the file is marked by a string "END"
it is definitely not a binary file.

Once in a while program hangs while reading.
The program doesn't exit but rather stays up and running, but never gets past this line. It doesn't even timeout(I hve set the time out to 2 minutes). neither does it throw any exception.

I do catch the socketException and IOException

Can anyone suggest what must be happening?

Thanks
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the while loop keep looping?
 
amar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This doesn't happen all the time, only once in a while.

The program freezes, it seems like it gets stuck at:

buffReader.readLine()
 
Jim Kiley
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thing I'd do is pretty simpleminded: Put a counter in the loop and pipe out to System.err the value of the counter -- is it infinite-looping, or is it hanging?

jk
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!