Java IO流下载图片问题

我在本地测试没有问题,线上下载的均为0k。
循环调用以下方法进行的批量下载,本地测试数据量较少,线上数据量多,不知道什么原因导致的,希望可以提供解决思路。


public static void main(String[] args) throws IOException {
 
        URL url1 = new URL("http://pic38.nipic.com/20140225/2531170_214014788000_2.jpg");
        URLConnection uc = url1.openConnection();
        InputStream inputStream = uc.getInputStream();
 
        FileOutputStream out = new FileOutputStream("D:\\image\\a.jpg");
        int j = 0;
        while ((j = inputStream.read()) != -1) {
            out.write(j);
        }
        inputStream.close();
 
    }



1、没看到你out.flush和out.close
2、读取二进制流一般是byte[]

因为你这是IO流,可以试试NIO异步IO