public class SftpLineReader extends Object implements LineReader, ConnectedTestable
Instances of this class are not safe for use by multiple threads.
LineReader.LineConsumer| Constructor and Description |
|---|
SftpLineReader(SftpChannel channel,
boolean autoCloseChannel)
Create a new SFTP line reader.
|
SftpLineReader(SftpChannel channel,
boolean autoCloseChannel,
String path)
Create a new SFTP line reader.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
exists(String pathToTest)
Test whether the given file path exists.
|
boolean |
isConnected()
Answer whether this object is currently connected.
|
ResultData |
readLines(LineReader.LineConsumer lineConsumer)
Read line by line until the current end.
|
ResultData |
readLines(LineReader.LineConsumer lineConsumer,
boolean autoConnect,
long timeoutInSeconds,
long tryIntervalInSeconds)
Read line by line until the current end.
|
void |
removePath()
Remove the current file path.
|
void |
setPath(String path)
Set the file path or null if you want to remove the current file path.
|
public SftpLineReader(SftpChannel channel, boolean autoCloseChannel)
channel - The SFTP channelautoCloseChannel - Flag whether to close the SFTP channel automatically when this reader will be closedIllegalArgumentException - if the SFTP channel is nullpublic SftpLineReader(SftpChannel channel, boolean autoCloseChannel, String path)
channel - The SFTP channelautoCloseChannel - Flag whether to close the SFTP channel automatically when this reader will be closedpath - The file pathIllegalArgumentException - if the SFTP channel is nullpublic final void setPath(String path)
Resets the internal pointer to the last imported byte.
setPath in interface LineReaderpath - The file pathIllegalStateException - if this reader is already closedIllegalArgumentException - if the path is not null but blankpublic final void removePath()
removePath in interface LineReaderIllegalStateException - if this reader is already closedpublic final ResultData readLines(LineReader.LineConsumer lineConsumer)
Each call to this methods tries to continue reading after the last imported byte from the previous call.
The internal pointer to the last imported byte can and will be reseted by setting or removing the path.
The auto-connect flag is set to true.
readLines in interface LineReaderlineConsumer - The consumer which takes line by lineIllegalStateException - if this reader is already closedIllegalArgumentException - if the line consumer is nullIllegalArgumentException - if the path is null or emptypublic final ResultData readLines(LineReader.LineConsumer lineConsumer, boolean autoConnect, long timeoutInSeconds, long tryIntervalInSeconds)
Each call to this methods tries to continue reading after the last imported byte from the previous call.
The internal pointer to the last imported byte can and will be reseted by setting or removing the path.
lineConsumer - The consumer which takes line by lineautoConnect - Flag whether to try to connect if not already connectedtimeoutInSeconds - The duration until timeout in seconds if autoConnect is true. A negative or zero value
means a one-time trytryIntervalInSeconds - The time interval between two subsequent tries in seconds if autoConnect is true.
Only relevant if the value of timeoutInSeconds is positive.IllegalStateException - if this reader is already closedIllegalArgumentException - if the line consumer is nullIllegalArgumentException - if the path is null or emptypublic final boolean exists(String pathToTest)
exists in interface LineReaderpathToTest - The file pathIllegalStateException - if this reader is already closedIllegalArgumentException - if the path is null or blankpublic final boolean isConnected()
ConnectedTestableisConnected in interface ConnectedTestablepublic final void close()
close in interface Closeableclose in interface AutoCloseableclose in interface LineReaderCopyright © 2019. All rights reserved.