package com.chat;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
public class UrlDemo {
public static void main(String[] args) throws IOException {
final URL url = new URL("http://file.znclass.com/1648534784367检查必传字段.mp4");
final URLConnection urlConnection = url.openConnection();
final InputStream inputStream = urlConnection.getInputStream();
final FileOutputStream fileOutputStream = new FileOutputStream("1.mp4");
final byte[] bytes = new byte[1024];
int len;
while ((len = inputStream.read(bytes)) != -1){
fileOutputStream.write(bytes,0 ,len);
}
fileOutputStream.close();
inputStream.close();
}
}
|