Reputation: 2100
How can we read single line from FTP server without downloading whole file using it.sauronsoftware.ftp4j.FTPClient.
Now, I am downloading whole file and than reading first line of file, is there any way we can read first line of file without download file in local machine. It should use only it.sauronsoftware.ftp4j
@http://www.sauronsoftware.it/projects/ftp4j/manual.php
NOTE : It should use it.sauronsoftware.ftp4j.FTPClient
and not apache
.
Upvotes: 0
Views: 936
Reputation: 144
Mohit,
Use the Socket dtConnection; dtConnection.getInputStream(); of ftp4j.FTPClient you will get InputStream, Using that InputStream you can read first line of.
you can find below Example hoe to read first line using InputStream
BufferedReader bufferedReader = null; String firstLine = null;
bufferedReader = new BufferedReader(new InputStreamReader(this.dataTransferInputStream, "UTF-8")); firstLine = bufferedReader.readLine();
Hope this solution will work for you.
Upvotes: 1
Reputation: 75629
You could make your own stream class that throws an exception after it has the first line written to it.
Edit: or it could call abortCurrentDataTransfer()
after it received the first line.
Upvotes: 0