Retrieve avatar profile image

This commit is contained in:
AsamK 2020-09-10 10:19:59 +02:00
parent 6c4d272309
commit 0f3aa22519
4 changed files with 85 additions and 35 deletions

View file

@ -4,8 +4,10 @@ import org.whispersystems.signalservice.internal.util.Util;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.nio.file.Files;
@ -77,4 +79,19 @@ public class IOUtils {
return System.getProperty("user.home") + "/.local/share";
}
public static void copyStreamToFile(InputStream input, File outputFile) throws IOException {
copyStreamToFile(input, outputFile, 8192);
}
public static void copyStreamToFile(InputStream input, File outputFile, int bufferSize) throws IOException {
try (OutputStream output = new FileOutputStream(outputFile)) {
byte[] buffer = new byte[bufferSize];
int read;
while ((read = input.read(buffer)) != -1) {
output.write(buffer, 0, read);
}
}
}
}