OSDN Git Service

動画ダウンロード時のバッファサイズ拡張
authoryukihane <yukihane.feather@gmail.com>
Mon, 22 Aug 2011 05:07:34 +0000 (14:07 +0900)
committeryukihane <yukihane.feather@gmail.com>
Mon, 22 Aug 2011 05:07:34 +0000 (14:07 +0900)
src/nicobrowser/NicoHttpClient.java

index dcb31bf..9447c1d 100644 (file)
@@ -722,17 +722,16 @@ public class NicoHttpClient {
         String ext = Util.getExtention(contentType);
         final long fileSize = response.getEntity().getContentLength();
 
-        // TODO バッファをもう少し大きくとる?
-        final int BUF_SIZE = 1024 * 32;
+        final int BUF_SIZE = 1024 * 512;
         BufferedInputStream in = null;
         BufferedOutputStream out = null;
         File file = new File(downloadFile.toString() + "." + ext);
         try {
-            in = new BufferedInputStream(response.getEntity().getContent());
+            in = new BufferedInputStream(response.getEntity().getContent(), BUF_SIZE);
 
             logger.info("保存します(" + fileSize / 1024 + "KB): " + file.getPath());
             FileOutputStream fos = new FileOutputStream(file);
-            out = new BufferedOutputStream(fos);
+            out = new BufferedOutputStream(fos, BUF_SIZE);
 
             long downloadSize = 0;
             int i;