Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!

purushotham mekalacheruvu

Greenhorn
+ Follow
since Apr 19, 2013
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by purushotham mekalacheruvu

Hi EveryOne, I saw some of the posts as ,to read a file from Remote Server they are telling first we have to download file to local and read that file.
from my point of view no need to download file. We can open an Inputstream on that file and read the content. below is the example.

String hostname = "";
String username = "";
String password = "";
//Connect to SFTP server location as below
SshParameters params = new SshParameters(hostname,username,password);
Sftp sftp = new Sftp(params);
sftp.connect();
//Once connected to server get InputStream as below

InputStream io = sftp.getInputStream(fileName,0L)// File name i.e to be read and second argument is offset
DataInputStream in = new DataInputStream(io);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
//Read line by line as below
String record="";
while((record=br.readLine()) != null){
// What ever you required
}

Please let me know if you have any questions..
mailId:purushotham635@gmail.com
6 years ago