BAEL-4856 Remove BinaryFileDownloadApplication.java and use correct indentation

This commit is contained in:
Iulian Manda
2021-06-03 18:13:09 +03:00
parent 4e8e10b5f9
commit f5c92c40f6
5 changed files with 117 additions and 149 deletions

View File

@@ -7,28 +7,28 @@ import java.io.OutputStream;
public class BinaryFileWriter implements AutoCloseable {
private static final int CHUNK_SIZE = 1024;
private final OutputStream outputStream;
private static final int CHUNK_SIZE = 1024;
private final OutputStream outputStream;
public BinaryFileWriter(OutputStream outputStream) {
this.outputStream = outputStream;
}
public long write(InputStream inputStream) throws IOException {
try (BufferedInputStream input = new BufferedInputStream(inputStream)) {
byte[] dataBuffer = new byte[CHUNK_SIZE];
int readBytes;
long totalBytes = 0;
while ((readBytes = input.read(dataBuffer)) != -1) {
totalBytes += readBytes;
outputStream.write(dataBuffer, 0, readBytes);
}
return totalBytes;
public BinaryFileWriter(OutputStream outputStream) {
this.outputStream = outputStream;
}
}
@Override
public void close() throws IOException {
outputStream.close();
}
public long write(InputStream inputStream) throws IOException {
try (BufferedInputStream input = new BufferedInputStream(inputStream)) {
byte[] dataBuffer = new byte[CHUNK_SIZE];
int readBytes;
long totalBytes = 0;
while ((readBytes = input.read(dataBuffer)) != -1) {
totalBytes += readBytes;
outputStream.write(dataBuffer, 0, readBytes);
}
return totalBytes;
}
}
@Override
public void close() throws IOException {
outputStream.close();
}
}