我正在做的是我正在为BufferOutputStream读取的文件和每行数据都将保存在FileOutputStream中,我想指定输出数据。
答案 0 :(得分:3)
如果我理解正确,你想从S3下载文件并使用BufferedOutputStream写入你的本地目录。
S3Object object = s3.getObject(new GetObjectRequest(bucketName, key));
InputStream is = object.getObjectContent();
// Creating file
File file= new File(localFilePath);
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos= new BufferedOutputStream(fos);
int read = -1;
while ((read = is.read()) != -1) {
bos.write(read);
}
bos.flush();
bos.close();
is.close();