• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to read a text file within remote ftp directory

 
Sonal Sharma
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42970
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42970
73
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!