I wrote a class, that uploads a file to a FTP server perfectly. Now I want to write the actual progress of the upload into a text file. How do I get the transferred bytes ? I tried the following method:
new CopyStreamAdapter() {
@Override
public void bytesTransferred(long totalBytesTransferred, int bytesTransferred, long streamSize) {
File uploadfile = new File(path);
try{
PrintWriter writer = new PrintWriter("C:\\Users\\lsp\\Desktop\\status.txt", "UTF-8");
writer.println((int)(totalBytesTransferred/uploadfile.length()) * 100);
writer.close();
} catch (IOException e) {
System.out.println("Fehler beim Schreiben der Datei.");
}
}
But Im not allowed to use it at the moment.