• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to read a text file within remote ftp directory

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear friends
How to read a text file within remote ftp directory?
My program is this.I have a directory named "Sample Files" on remote ftp server which contains a text file batch2.txt.I want to read that file.Please tell me how to do it.Here is my program:


JCE- added code tags
[ April 23, 2008: Message edited by: Joe Ess ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code you posted looks like an FTP client, so I'm not sure what you're still looking for. If it doesn't do what you are trying to accomplish, tell us in detail what it does do, and where its behavior is different from the desired behavior.

Also, please edit your post to UseCodeTags. It's unnecessarily hard to read as it is.
 
Sonal Sharma
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you are right Ulff.I am trying to read a text file within a ftp server directory using jscape libraries or jar files.How to do it?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once again:

The code you posted looks like an FTP client, so I'm not sure what you're still looking for. If it doesn't do what you are trying to accomplish, tell us in detail what it does do, and where its behavior is different from the desired behavior.

 
Sonal Sharma
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Ulff,
Yes you are right.This is a ftp client program using libraries from jscape. How to read a text file within remote ftp directory?
My program is this.I have a directory named "Sample Files" on remote ftp server which contains a text file batch2.txt.I want to read that file.Please tell me how to do it.Here is my program:

// only print files that are directories;if(file.isDirectory()) {System.out.println(file.getFilename());String fileName = file.getFilename();String fileName1 = "Sample files";if(fileName.equals(fileName1)){ File fl1 = new File(fileName,"batch2.txt"); try { FileReader fr1 = new FileReader(fl1); BufferedReader br = new BufferedReader(fr1); String s = null; while((s = br.readLine())!=null) System.out.println(s); br.close(); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags and make sure the code is indented; it is illegible as it is.

The code snippet doesn't do any FTP operation, so I'm not sure how it is relevant to the question. The first piece of code does do FTP; if you have difficulties using it for the task you need to do, tell us what you have tried, and how it's not working. You can also post the code you're using now; just make sure -see above- to properly post it so it's readable.
 
What are you doing? You are supposed to be reading this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic