public class SftpLineWriter extends Object implements LineWriter, ConnectedTestable
Instances of this class are not safe for use by multiple threads.
| Constructor and Description |
|---|
SftpLineWriter(SftpChannel channel,
boolean autoCloseChannel)
Create a new SFTP line writer.
|
SftpLineWriter(SftpChannel channel,
boolean autoCloseChannel,
String path)
Create a new SFTP line writer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
isConnected()
Answer whether this object is currently connected.
|
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.
|
ResultData |
writeLines(Supplier<String> lineSupplier)
Write line by line until the line supplier provides a null value.
|
ResultData |
writeLines(Supplier<String> lineSupplier,
boolean autoConnect,
long timeoutInSeconds,
long tryIntervalInSeconds)
Write line by line until the line supplier provides a null value.
|
public SftpLineWriter(SftpChannel channel, boolean autoCloseChannel)
channel - The SFTP channelautoCloseChannel - Flag whether to close the SFTP channel automatically when this writer will be closedIllegalArgumentException - if the SFTP channel is nullpublic SftpLineWriter(SftpChannel channel, boolean autoCloseChannel, String path)
channel - The SFTP channelautoCloseChannel - Flag whether to close the SFTP channel automatically when this writer will be closedpath - The file pathIllegalArgumentException - if the SFTP channel is nullpublic final void setPath(String path)
setPath in interface LineWriterpath - The file pathIllegalStateException - if this writer is already closedIllegalArgumentException - if the path is not null but blankpublic final void removePath()
removePath in interface LineWriterIllegalStateException - if this writer is already closedpublic final ResultData writeLines(Supplier<String> lineSupplier)
Each call to this methods tries to continue writing after the last exported byte from the previous call.
The internal pointer to the last exported byte can and will be reseted by setting or removing the path.
The auto-connect flag is set to true.
writeLines in interface LineWriterlineSupplier - The supplier which provides line by line. A null value indicates the end.IllegalStateException - if this writer is already closedIllegalArgumentException - if the line supplier is nullIllegalArgumentException - if the path is null or emptypublic final ResultData writeLines(Supplier<String> lineSupplier, boolean autoConnect, long timeoutInSeconds, long tryIntervalInSeconds)
Each call to this methods tries to continue writing after the last exported byte from the previous call.
The internal pointer to the last exported byte can and will be reseted by setting or removing the path.
lineSupplier - The supplier which provides line by line. A null value indicates the end.autoConnect - 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 writer is already closedIllegalArgumentException - if the line supplier is nullIllegalArgumentException - if the path is null or emptypublic final boolean isConnected()
ConnectedTestableisConnected in interface ConnectedTestablepublic final void close()
close in interface Closeableclose in interface AutoCloseableclose in interface LineWriterCopyright © 2019. All rights reserved.