I want to write data to a file(If present then append else create new) present on my ftp server(locally running). I am having a List<byte[]> of a file.
public void write(List<byte[]> bytes, String path)throws Exception{
URL url = new URL(path);
URLConnection conn = url.openConnection();
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
for (byte[] byte : bytes) {
out.write(byte);
}
out.close();
}
NOTE: Path could be an HTTP or FTP or SFTP url.
It is overwriting on file. I want to append in file which is already present at that location. How to enable append mode in OutputStream?