标签:AC generate exce http catch style NPU sys last
下载图片
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
public static void main(String[] args) { // TODO Auto-generated method stub
//图片线上地址:xxx
File file1=new File("xxx"); String name = file1.getName(); File file2=new File("F:\\bbb\\"+name);//本地地址 try { URL url = new URL("https://hlww.oss-cn-shanghai.aliyuncs.com/hlww/pic/img_32_1521892791.jpeg "); BufferedInputStream in = new BufferedInputStream(url.openStream()); FileOutputStream out = new FileOutputStream(file2); int t; while ((t = in.read()) != -1) { out.write(t); } out.close(); in.close(); System.out.println("图片获取成功"); }catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.out.println("fileName:"+name); String prefix1=name.substring(name.lastIndexOf(".")); System.out.println(prefix1+"....."); }
标签:AC generate exce http catch style NPU sys last
原文地址:https://www.cnblogs.com/dztHome/p/8890954.html