File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes How do I read a file saved on a SFTP server using  jScape's SFTP Api Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "How do I read a file saved on a SFTP server using  jScape Watch "How do I read a file saved on a SFTP server using  jScape New topic
Author

How do I read a file saved on a SFTP server using jScape's SFTP Api

Aniruddh Joshi
Ranch Hand

Joined: Jul 29, 2008
Posts: 275

Hi All,

I have a scheduler in my application which periodically processes XML files saved on a FTP server. Recently my organisation has replaced the server with a SFTP server.
I have downloaded the API SFTP.zip and am trying to implement the following steps :
1) connect to the server
2) change the directory
3) read an XML file .

The first two steps are running without an excpetion, but I can't find a counterpart of

Quote:
byte[] result = ftp.get(fileName);

which I was using for normal FTP server.

My incomplete code follows :




Please let me know if such an implementation is possible .
If not, please suggest a way using which I can read XML files stored on SFTP server and after reading rename the file with a suffix '.PROCESSED'.

Thanks in advance

[ November 10, 2008: Message edited by: Aniruddh Joshi ]

[ November 10, 2008: Message edited by: Aniruddh Joshi ]
[ November 10, 2008: Message edited by: Aniruddh Joshi ]

Anrd
"One of the best things you could do is to simplify a larger application into a smaller one by reducing its process and complexity - Fowler"
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

I Googled quickly for this class, and I see methods named "download()", which generally place the downloaded data into a file for you, or "getInputStream()" which would allow you to read the data into an array (if that's what you wanted to do.) Did you look at the Javadoc?


[Jess in Action][AskingGoodQuestions]
Sivapraveen Chandana
Greenhorn

Joined: Jan 01, 2008
Posts: 16
Hi Aniruddh,
Actually, I am not replying to your question.
The point is I too need to develop a tool that does similar kind of processing as you need to. Pleae tell where did you download the SFTP API from ?
And, where can I get all other related API like FTP, SSH etc.

Anybody who knows this, please reply....

Thanks..


praveen
Aniruddh Joshi
Ranch Hand

Joined: Jul 29, 2008
Posts: 275

Thanks Ernest,

I've tried dowmload() but its not what I want. Actually the javadoc which came with the download are incomplete.
I'll try to use getInputStream as it fitsd the requirement.

Siva,
You can download the API from jscape.com, A number of such API's are available but very few are free.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How do I read a file saved on a SFTP server using jScape's SFTP Api