use of com.trilead.ssh2.SFTPv3FileHandle in project Payara by payara.
the class SFTPClient method read.
public InputStream read(String file) throws IOException {
file = normalizePath(file);
final SFTPv3FileHandle h = openFileRO(file);
return new InputStream() {
private long offset = 0;
public int read() throws IOException {
byte[] b = new byte[1];
if (read(b) < 0)
return -1;
return b[0];
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
int r = SFTPClient.this.read(h, offset, b, off, len);
if (r < 0)
return -1;
offset += r;
return r;
}
@Override
public long skip(long n) throws IOException {
offset += n;
return n;
}
@Override
public void close() throws IOException {
closeFile(h);
}
};
}
Aggregations