2012-04-05 76 views

回答

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(); 
+0

是的。謝謝soooooo mcuch!你真棒! – 2012-04-06 16:24:41

相關問題