本文共 807 字,大约阅读时间需要 2 分钟。
package com.tencent.UDP; import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.net.HttpURLConnection;import java.net.URL;public class Download { public static void main(String[] args) throws IOException { URL url = new URL("http://m.0714news.com/videos/b4e0ba24a77940aa.mp4"); HttpURLConnection u = (HttpURLConnection)url.openConnection(); InputStream is = u.getInputStream(); FileOutputStream fos = new FileOutputStream("C://Users//mibook//Desktop//jay.mp4"); byte[] buffer = new byte[1024]; int len = 0; while((len = is.read(buffer)) != -1) { fos.write(buffer , 0 , buffer.length); System.out.println(buffer); } fos.close(); is.close(); u.disconnect(); }}
转载地址:http://sjpt.baihongyu.com/