OSDN Git Service

リファクタリング
authoryuki <yuki@bdf3b611-c98c-6041-8292-703d9c9adbe7>
Tue, 1 Dec 2009 11:29:48 +0000 (11:29 +0000)
committeryuki <yuki@bdf3b611-c98c-6041-8292-703d9c9adbe7>
Tue, 1 Dec 2009 11:29:48 +0000 (11:29 +0000)
git-svn-id: http://192.168.11.7/svn/repository/NicoBrowser/trunk@268 bdf3b611-c98c-6041-8292-703d9c9adbe7

src/nicobrowser/NicoHttpClient.java

index b4d6d9c..5d5928a 100644 (file)
@@ -527,8 +527,6 @@ public class NicoHttpClient extends DefaultHttpClient {
     public GetFlvResult getFlvFile(String videoID, String fileName, Status nowStatus, boolean needLowFile) throws
             IOException,
             URISyntaxException, HttpException, InterruptedException {
-        byte[] buffer = new byte[1024 * 32];
-
         String watchUrl = "http://www.nicovideo.jp/watch/" + videoID;
         log.debug("アクセス: " + watchUrl);
         getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
@@ -580,14 +578,16 @@ public class NicoHttpClient extends DefaultHttpClient {
         String ext = Util.getExtention(contentType);
         final long fileSize = response.getEntity().getContentLength();
 
+        final int BUF_SIZE = 1024 * 32;
         BufferedInputStream in = new BufferedInputStream(response.getEntity().getContent());
 
         File file = new File(fileName + "." + ext);
-        log.info("" + fileSize / 1024 / 1024 + "MBを保存します: " + file.getPath());
+        log.info("保存します(" + fileSize / 1024 + "KB): " + file.getPath());
         FileOutputStream fos = new FileOutputStream(file);
         BufferedOutputStream out = new BufferedOutputStream(fos);
 
         int i;
+        byte[] buffer = new byte[BUF_SIZE];
         while ((i = in.read(buffer)) != -1) {
             out.write(buffer, 0, i);
         }