I’m trying to read the file on the FTP remote-server using Apache Commons Net library.
InputStream and put it in
But, I want to use
RandomAccessFile (to use the
I want to get
Inputstream as a
Is it possible?
FTPClient ftp = new FTPClient(); InputStream in = ftp.retrieveFileStream(remote_file_name); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
If you want to starting reading the remote file from a certain offset, use
FTPClient.setRestartOffset. The FTP server needs to support
REST command (most do).
ftp.setRestartOffset(offset); InputStream in = ftp.retrieveFileStream(remote_file_name); // Now you can read as many bytes as you need from 'in'
If you do not want to read the file to the end, and you want to reuse the connection for other operations, you need to call
(You cannot convert
RandomAccessFile, nor use
RandomAccessFile anyhow with files on FTP server)