• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

read from a file on FTP server

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the while loop keep looping?
 
amar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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()
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic