principal-ideal-domain
principal-ideal-domain

Reputation: 4276

Modified FileInputStream (certain part of the file)

How can I get a FileInputStream of an existing file which doesn't go through the whole file but rather goes through a specified part of the file (from byte m till byte n)?

Edit: I need the FileInputStream to submit it to org.apache.commons.net.ftp.FTPClient.storeFile.

Upvotes: 1

Views: 320

Answers (1)

user4413257
user4413257

Reputation:

File file = ...
FileInputStream fis = new FileInputStream(file);
long m = .... 
fis.getChannel().position(m);
int n = ... 
byte[] buffer = new byte[n];
fis.read(buffer);    

Upvotes: 1

Related Questions