Я пытался добиться того же, и ответы на эти вопросы мне очень помогли:
Добавление символов в начало и конец InputStream в Java (помеченный справа показывает, как добавить пользовательскую строку в InputStream)
Загрузка файла на FTP-сервер с телефона Android? (в Kumar Vivek Mitra показано, как загрузить файл)
Я добавил новый текст в конец моего онлайн-файла, например:
FTPClient con = null;
try {
con = new FTPClient();
con.connect(Hostname);
if (con.login(FTPUsername, FTPPassword)) {
con.enterLocalPassiveMode(); // important!
con.setFileType(FTP.BINARY_FILE_TYPE);
InputStream onlineDataIS = urlOfOnlineFile.openStream();
String end = "\nteeeeeeeeeeeeeeeeest";
List<InputStream> streams = Arrays.asList(
onlineDataIS,
new ByteArrayInputStream(end.getBytes()));
InputStream resultIS = new SequenceInputStream(Collections.enumeration(streams));
// Stores a file on the server using the given name and taking input from the given InputStream.
boolean result = con.storeFile(PathOfTargetFile, resultIS);
onlineDataIS.close();
resultIS.close();
if (result) Log.v("upload result", "succeeded");
con.logout();
con.disconnect();
}
return "Writing successful";
} catch (IOException e) {
// some smart error handling
}
Надеюсь, это поможет.